Preserve tag field focus when switching between cards

This commit is contained in:
Glutanimate 2017-03-01 20:25:59 +01:00
parent 17d68cc957
commit 8f7f7db861

View File

@ -1518,8 +1518,12 @@ update cards set usn=?, mod=?, did=? where id in """ + scids,
self.editor.saveNow(self._onPreviousCard) self.editor.saveNow(self._onPreviousCard)
def _onPreviousCard(self): def _onPreviousCard(self):
tagfocus = self.editor.tags.hasFocus()
f = self.editor.currentField f = self.editor.currentField
self._moveCur(QAbstractItemView.MoveUp) self._moveCur(QAbstractItemView.MoveUp)
if tagfocus:
self.editor.tags.setFocus()
return
self.editor.web.setFocus() self.editor.web.setFocus()
self.editor.web.eval("focusField(%d)" % f) self.editor.web.eval("focusField(%d)" % f)
@ -1527,8 +1531,12 @@ update cards set usn=?, mod=?, did=? where id in """ + scids,
self.editor.saveNow(self._onNextCard) self.editor.saveNow(self._onNextCard)
def _onNextCard(self): def _onNextCard(self):
tagfocus = self.editor.tags.hasFocus()
f = self.editor.currentField f = self.editor.currentField
self._moveCur(QAbstractItemView.MoveDown) self._moveCur(QAbstractItemView.MoveDown)
if tagfocus:
self.editor.tags.setFocus()
return
self.editor.web.setFocus() self.editor.web.setFocus()
self.editor.web.eval("focusField(%d)" % f) self.editor.web.eval("focusField(%d)" % f)