From f48b3b27da23161131fdb25a7f7e197ea915bd4d Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 29 Mar 2011 18:01:55 +0900 Subject: [PATCH] hack to prevent keys from leaking from other widgets --- aqt/webview.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/aqt/webview.py b/aqt/webview.py index 8f93e6100..4dca45a92 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -53,7 +53,16 @@ class AnkiWebView(QWebView): self.setKeyHandler() self.connect(self, SIGNAL("linkClicked(QUrl)"), self._linkHandler) self.connect(self, SIGNAL("loadFinished(bool)"), self._loadFinished) + self._curKey = None + def keyPressEvent(self, evt): + self._curKey = True + return QWebView.keyPressEvent(self, evt) def keyReleaseEvent(self, evt): + if not self._curKey: + # event didn't start with us + evt.ignore() + return + self._curKey = None if evt.matches(QKeySequence.Copy): self.triggerPageAction(QWebPage.Copy) evt.accept()