From 62629975993476e0920f9206d056be4f6f88d2a0 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Wed, 20 Jan 2021 17:01:16 +0100 Subject: [PATCH] Explicitly execute code deactivating button focus from editor.py --- qt/aqt/data/web/js/editor.ts | 15 ++++++++------- qt/aqt/editor.py | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) 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 ######################################################################