Skip to content

Commit f166358

Browse files
committed
[CEF] Fix focus
1 parent 8ce92c8 commit f166358

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

webview/platforms/cef.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def load_html(self, html):
145145
self.loaded.clear()
146146
self.browser.LoadUrl('data:text/html,{0}'.format(html))
147147

148+
def focus(self):
149+
self.browser.SendFocusEvent(True)
150+
148151

149152
def find_instance(browser):
150153
for instance in instances.values():
@@ -256,6 +259,12 @@ def _create():
256259
cef.PostTask(cef.TID_UI, _create)
257260

258261

262+
@_cef_call
263+
def focus(uid):
264+
instance = instances[uid]
265+
instance.focus()
266+
267+
259268
@_cef_call
260269
def load_html(html, uid):
261270
instance = instances[uid]

webview/platforms/winforms.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,14 @@ def on_activated(self, sender, args):
238238
if self.browser:
239239
self.browser.web_view.Focus()
240240

241+
if is_cef:
242+
CEF.focus(self.uid)
243+
241244
def on_shown(self, sender, args):
242-
if not is_cef:
245+
if is_cef:
246+
CEF.focus(self.uid)
247+
else:
243248
self.shown.set()
244-
245-
if self.browser:
246249
self.browser.web_view.Focus()
247250

248251
def on_close(self, sender, args):

0 commit comments

Comments
 (0)