mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix scrolling with keys / keyboard event listeners not working on answer side (#2099)
* Revert "Fix reviewer shortcuts being inaccessible due to IME"
This reverts commit 5bf031f1e3
.
* Work around WebEngine/IME bug in Qt6
This commit is contained in:
parent
da4d80da2a
commit
76065e843b
3 changed files with 17 additions and 8 deletions
|
@ -653,12 +653,6 @@ class Reviewer:
|
||||||
def _onTypedAnswer(self, val: None) -> None:
|
def _onTypedAnswer(self, val: None) -> None:
|
||||||
self.typedAnswer = val or ""
|
self.typedAnswer = val or ""
|
||||||
self._showAnswer()
|
self._showAnswer()
|
||||||
self.unfocus_typing_box()
|
|
||||||
|
|
||||||
def unfocus_typing_box(self) -> None:
|
|
||||||
# shifting focus to the bottom area works around a WebEngine/IME bug
|
|
||||||
# https://github.com/ankitects/anki/issues/1952
|
|
||||||
self.bottom.web.setFocus()
|
|
||||||
|
|
||||||
# Bottom bar
|
# Bottom bar
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -294,8 +294,9 @@ class AnkiWebView(QWebEngineView):
|
||||||
w.close()
|
w.close()
|
||||||
else:
|
else:
|
||||||
# in the main window, removes focus from type in area
|
# in the main window, removes focus from type in area
|
||||||
if mw.state == "review":
|
parent = self.parent()
|
||||||
mw.reviewer.unfocus_typing_box()
|
assert isinstance(parent, QWidget)
|
||||||
|
parent.setFocus()
|
||||||
break
|
break
|
||||||
w = w.parent()
|
w = w.parent()
|
||||||
|
|
||||||
|
|
|
@ -237,3 +237,17 @@ export function _blockDefaultDragDropBehavior(): void {
|
||||||
document.ondragover = handler;
|
document.ondragover = handler;
|
||||||
document.ondrop = handler;
|
document.ondrop = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// work around WebEngine/IME bug in Qt6
|
||||||
|
// https://github.com/ankitects/anki/issues/1952
|
||||||
|
const dummyButton = document.createElement("button");
|
||||||
|
dummyButton.style.position = "absolute";
|
||||||
|
dummyButton.style.left = "-9999px";
|
||||||
|
document.addEventListener("focusout", (event) => {
|
||||||
|
const target = event.target;
|
||||||
|
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
||||||
|
document.body.appendChild(dummyButton);
|
||||||
|
dummyButton.focus();
|
||||||
|
document.body.removeChild(dummyButton);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue