Basic fix for shortcuts

This commit is contained in:
Luc Mcgrady 2025-10-07 01:10:25 +01:00
parent 19f1df3a02
commit 9550b127d9
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
3 changed files with 33 additions and 0 deletions

View file

@ -1298,6 +1298,9 @@ class SvelteReviewer(Reviewer):
self.bottom.web = self.web
self.mw.bottomWeb.hide()
def _shortcutKeys(self) -> Sequence[tuple[str, Callable] | tuple[Qt.Key, Callable]]:
return []
# if the last element is a comment, then the RUN_STATE_MUTATION code
# breaks due to the comment wrongly commenting out python code.

View file

@ -10,6 +10,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
$: if (iframe) {
state.registerIFrame(iframe);
state.registerShortcuts();
}
</script>

View file

@ -25,6 +25,35 @@ export class ReviewerState {
iframe.addEventListener("load", this.onReady.bind(this));
}
onKeyDown(e: KeyboardEvent) {
switch (e.key) {
case "1": {
this.easeButtonPressed(0);
break;
}
case "2": {
this.easeButtonPressed(1);
break;
}
case "3": {
this.easeButtonPressed(2);
break;
}
case "4": {
this.easeButtonPressed(3);
break;
}
case " ": {
this.showAnswer();
break;
}
}
}
public registerShortcuts() {
document.addEventListener("keydown", this.onKeyDown.bind(this));
}
updateHtml(htmlString: string) {
this.iframe?.contentWindow?.postMessage({ type: "html", value: htmlString }, "*");
}