From 1af556cb8d62a638f7fa0bcb6289bf932d338691 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 23 Oct 2018 16:06:56 +1000 Subject: [PATCH] delay event filter installation Qt 5.11 doesn't initialize the focusProxy until a page has been loaded. --- aqt/webview.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aqt/webview.py b/aqt/webview.py index 21ea9360a..beb4a8ecd 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -97,6 +97,7 @@ class AnkiWebView(QWebEngineView): self._page.profile().setHttpCacheType(QWebEngineProfile.NoCache) self.resetHandlers() self.allowDrops = False + self._filterSet = False QShortcut(QKeySequence("Esc"), self, context=Qt.WidgetWithChildrenShortcut, activated=self.onEsc) if isMac: @@ -112,8 +113,6 @@ class AnkiWebView(QWebEngineView): QShortcut(QKeySequence("ctrl+shift+v"), self, context=Qt.WidgetWithChildrenShortcut, activated=self.onPaste) - self.focusProxy().installEventFilter(self) - def eventFilter(self, obj, evt): # disable pinch to zoom gesture if isinstance(evt, QNativeGestureEvent): @@ -327,6 +326,10 @@ body {{ zoom: {}; {} }} return False def _onBridgeCmd(self, cmd): + if not self._filterSet: + self.focusProxy().installEventFilter(self) + self._filterSet = True + if self._shouldIgnoreWebEvent(): print("ignored late bridge cmd", cmd) return