focus correct field on tab/backtab

This commit is contained in:
Damien Elmes 2012-04-24 08:27:40 +09:00
parent b6adc9f1bb
commit 954c5171e3

View file

@ -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