diff --git a/qt/aqt/data/web/js/editor.ts b/qt/aqt/data/web/js/editor.ts index af89b4e7c..85483078c 100644 --- a/qt/aqt/data/web/js/editor.ts +++ b/qt/aqt/data/web/js/editor.ts @@ -294,6 +294,14 @@ function wrappedExceptForWhitespace(text: string, front: string, back: string): return match[1] + front + match[2] + back + match[3]; } +function preventButtonFocus(): void { + for (const element of document.querySelectorAll("button.linkb")) { + element.addEventListener("mousedown", (evt: Event) => { + evt.preventDefault(); + }); + } +} + function disableButtons(): void { $("button.linkb:not(.perm)").prop("disabled", true); } @@ -619,13 +627,6 @@ document.addEventListener("click", (evt: MouseEvent): void => { } }); -// prevent editor buttons from taking focus -for (const element of document.querySelectorAll("button.linkb")) { - element.addEventListener("mousedown", (evt: Event) => { - evt.preventDefault(); - }); -} - window.addEventListener("resize", () => { adjustFieldsTopMargin(); }); diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index bbe3a4add..342bdb877 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -222,6 +222,7 @@ class Editor: js=["js/vendor/jquery.min.js", "js/editor.js"], context=self, ) + self.web.eval("preventButtonFocus();") # Top buttons ######################################################################