Skip to content

Commit

Permalink
Fix QLineEdit focus issues in qt.py example on Windows (#404).
Browse files Browse the repository at this point in the history
Revert previous commit.
  • Loading branch information
cztomczak committed Jan 22, 2020
1 parent a314559 commit 181588c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions examples/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ def __init__(self, parent=None):
def focusInEvent(self, event):
# This event seems to never get called on Linux, as CEF is
# stealing all focus due to Issue #284.
if cef.GetAppSetting("debug"):
print("[qt.py] CefWidget.focusInEvent")
if self.browser:
if WINDOWS:
WindowUtils.OnSetFocus(self.getHandle(), 0, 0, 0)
Expand All @@ -220,6 +222,8 @@ def focusInEvent(self, event):
def focusOutEvent(self, event):
# This event seems to never get called on Linux, as CEF is
# stealing all focus due to Issue #284.
if cef.GetAppSetting("debug"):
print("[qt.py] CefWidget.focusOutEvent")
if self.browser:
self.browser.SetFocus(False)

Expand Down Expand Up @@ -336,18 +340,20 @@ class FocusHandler(object):
def __init__(self, cef_widget):
self.cef_widget = cef_widget

def OnTakeFocus(self, **_):
if cef.GetAppSetting("debug"):
print("[qt.py] FocusHandler.OnTakeFocus")

def OnSetFocus(self, **_):
print("[qt.py] FocusHandler.OnSetFocus")
if LINUX:
return False
else:
return True
if cef.GetAppSetting("debug"):
print("[qt.py] FocusHandler.OnSetFocus")

def OnGotFocus(self, browser, **_):
if cef.GetAppSetting("debug"):
print("[qt.py] FocusHandler.OnGotFocus")
self.cef_widget.setFocus()
# Temporary fix no. 1 for focus issues on Linux (Issue #284)
if LINUX:
print("[qt.py] FocusHandler.OnGotFocus:"
" keyboard focus fix no. 1 (Issue #284)")
browser.SetFocus(True)


Expand Down

0 comments on commit 181588c

Please sign in to comment.