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