mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
set focus when adding/editing current
This commit is contained in:
parent
af7d813a2a
commit
9ed0535a8b
1 changed files with 9 additions and 2 deletions
|
@ -189,6 +189,9 @@ function setFields(fields, focusTo) {
|
||||||
if (!focusTo) {
|
if (!focusTo) {
|
||||||
focusTo = 0;
|
focusTo = 0;
|
||||||
}
|
}
|
||||||
|
if (focusTo >= 0) {
|
||||||
|
$("#f"+focusTo).focus();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function setBackgrounds(cols) {
|
function setBackgrounds(cols) {
|
||||||
|
@ -444,9 +447,10 @@ class Editor(object):
|
||||||
if self.note:
|
if self.note:
|
||||||
self.loadNote()
|
self.loadNote()
|
||||||
|
|
||||||
def setNote(self, note, hide=True):
|
def setNote(self, note, hide=True, focus=False):
|
||||||
"Make NOTE the current note."
|
"Make NOTE the current note."
|
||||||
self.note = note
|
self.note = note
|
||||||
|
self.currentField = 0
|
||||||
# change timer
|
# change timer
|
||||||
if self.note:
|
if self.note:
|
||||||
self.web.setHtml(_html % (getBase(self.mw.col), anki.js.jquery,
|
self.web.setHtml(_html % (getBase(self.mw.col), anki.js.jquery,
|
||||||
|
@ -461,7 +465,10 @@ class Editor(object):
|
||||||
self.widget.hide()
|
self.widget.hide()
|
||||||
|
|
||||||
def loadNote(self):
|
def loadNote(self):
|
||||||
field = self.currentField
|
if self.stealFocus:
|
||||||
|
field = self.currentField
|
||||||
|
else:
|
||||||
|
field = -1
|
||||||
if not self._loaded:
|
if not self._loaded:
|
||||||
# will be loaded when page is ready
|
# will be loaded when page is ready
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue