Skip to content

Commit 0572d2f

Browse files
committed
Fixed keyboard problems when embedding browser in wx tabs,
see this topic: http://magpcss.org/ceforum/viewtopic.php?f=6&t=10922 There is still similar issue for popup windows remaining to be fixed, see Issue 80.
1 parent 6ec1d43 commit 0572d2f

8 files changed

Lines changed: 39 additions & 6 deletions

File tree

cefpython/cef3/linux/binaries_32bit/wxpython.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def __init__(self):
9999

100100
# Cannot attach browser to the main frame as this will cause
101101
# the menu not to work.
102-
self.mainPanel = wx.Panel(self)
102+
# --
103+
# You also have to set the wx.WANTS_CHARS style for
104+
# all parent panels/controls, if it's deeply embedded.
105+
self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)
103106

104107
windowInfo = cefpython.WindowInfo()
105108
windowInfo.SetAsChild(self.mainPanel.GetGtkWidget())

cefpython/cef3/linux/binaries_64bit/wxpython.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def __init__(self):
9999

100100
# Cannot attach browser to the main frame as this will cause
101101
# the menu not to work.
102-
self.mainPanel = wx.Panel(self)
102+
# --
103+
# You also have to set the wx.WANTS_CHARS style for
104+
# all parent panels/controls, if it's deeply embedded.
105+
self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)
103106

104107
windowInfo = cefpython.WindowInfo()
105108
windowInfo.SetAsChild(self.mainPanel.GetGtkWidget())

cefpython/cef3/windows/binaries/example.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ <h3>Advanced example</h3>
4949
client handlers and others.
5050

5151

52+
<br><br><br><br>
53+
<br><br><br><br>
54+
<br><br><br><br>
55+
<br><br><br><br>
5256

5357
</body>
5458
</html>

cefpython/cef3/windows/binaries/wxpython.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ <h3>User agent</h3>
2727
<h3>Popup</h3>
2828
<a href="javascript:window.open('wxpython.html')">
2929
window.open('wxpython.html')</a>
30+
<br>
31+
<a target=_blank href="wxpython.html">
32+
wxpython.html (target=_blank)</a>
3033

3134

3235

@@ -40,6 +43,15 @@ <h3>HTML5 video and accelerated content</h3>
4043

4144

4245

46+
<h3>Test forms</h3>
47+
48+
<select><option>opt 1</option><option>opt 2</option></select>
49+
<br>
50+
<input type=text>
51+
<br>
52+
<textarea></textarea>
53+
54+
4355
<h3>Javascript bindings</h3>
4456
<a href="javascript:PyPrint('printing in python console from js')">
4557
PyPrint('printing in python console from js')</a><br>

cefpython/cef3/windows/binaries/wxpython.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# It seems that Flash content behaves better when using a timer.
3333
USE_EVT_IDLE = True
3434

35-
TEST_EMBEDDING_IN_PANEL = False
35+
TEST_EMBEDDING_IN_PANEL = True
3636

3737
def GetApplicationPath(file=None):
3838
import re, os, platform
@@ -103,7 +103,9 @@ def __init__(self):
103103

104104
if TEST_EMBEDDING_IN_PANEL:
105105
print("Embedding in a wx.Panel!")
106-
self.mainPanel = wx.Panel(self)
106+
# You also have to set the wx.WANTS_CHARS style for
107+
# all parent panels/controls, if it's deeply embedded.
108+
self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)
107109

108110
windowInfo = cefpython.WindowInfo()
109111
windowInfo.SetAsChild(self.GetHandleForBrowser())

cefpython/cef3/wx-subpackage/chromectrl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ class ChromeCtrl(wx.Panel):
177177
def __init__(self, parent, url="", useTimer=False,
178178
timerMillis=DEFAULT_TIMER_MILLIS, hasNavBar=True,
179179
*args, **kwargs):
180-
wx.Panel.__init__(self, parent, *args, **kwargs)
180+
# You also have to set the wx.WANTS_CHARS style for
181+
# all parent panels/controls, if it's deeply embedded.
182+
wx.Panel.__init__(self, parent, style=wx.WANTS_CHARS, *args, **kwargs)
181183

182184
self.chromeWindow = ChromeWindow(self, url=str(url), useTimer=useTimer)
183185
sizer = wx.BoxSizer(wx.VERTICAL)

cefpython/cef3/wx-subpackage/examples/sample2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ def initComponents(self):
3333
self.tree.AppendItem(self.root, url)
3434
self.tree.Expand(self.root)
3535

36-
self.tabs = fnb.FlatNotebook(self, wx.ID_ANY, agwStyle=fnb.FNB_NODRAG | fnb.FNB_X_ON_TAB)
36+
self.tabs = fnb.FlatNotebook(self, wx.ID_ANY,
37+
agwStyle=fnb.FNB_NODRAG | fnb.FNB_X_ON_TAB)
38+
# You also have to set the wx.WANTS_CHARS style for
39+
# all parent panels/controls, if it's deeply embedded.
40+
self.tabs.SetWindowStyleFlag(wx.WANTS_CHARS)
3741

3842
def layoutComponents(self):
3943
sizer = wx.BoxSizer(wx.HORIZONTAL)

cefpython/cef3/wx-subpackage/examples/sample3.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def __init__(self):
1717
def _InitComponents(self):
1818
self.tabs = fnb.FlatNotebook(self, wx.ID_ANY,
1919
agwStyle=fnb.FNB_NODRAG|fnb.FNB_X_ON_TAB)
20+
# You also have to set the wx.WANTS_CHARS style for
21+
# all parent panels/controls, if it's deeply embedded.
22+
self.tabs.SetWindowStyleFlag(wx.WANTS_CHARS)
2023

2124
ctrl1 = chrome.ChromeCtrl(self.tabs, useTimer=True,
2225
url="wikipedia.org")

0 commit comments

Comments
 (0)