diff --git a/aqt/editor.py b/aqt/editor.py index 1703c86d0..63985a10c 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -119,6 +119,10 @@ function onFocus(elem) { } } +function focusField(n) { + $("#f"+n).focus(); +} + function onDragOver(elem) { elem.focus(); } @@ -894,6 +898,14 @@ class EditorWebView(AnkiWebView): else: AnkiWebView.mouseReleaseEvent(self, evt) + def focusInEvent(self, evt): + AnkiWebView.focusInEvent(self, evt) + if evt.reason() == Qt.TabFocusReason: + self.eval("focusField(0);") + elif evt.reason() == Qt.BacktabFocusReason: + n = len(self.editor.note.fields) - 1 + self.eval("focusField(%d);" % n) + # Buggy; disable for now. # def contextMenuEvent(self, evt): # # adjust in case the user is going to paste