make sure we focus first field when adding next note (#605)

This commit is contained in:
Damien Elmes 2013-05-22 12:54:29 +09:00
parent e61e849e09
commit 04b010a6d1
2 changed files with 5 additions and 3 deletions

View file

@ -76,7 +76,7 @@ class AddCards(QDialog):
def setupNewNote(self, set=True): def setupNewNote(self, set=True):
f = self.mw.col.newNote() f = self.mw.col.newNote()
if set: if set:
self.editor.setNote(f) self.editor.setNote(f, focus=True)
return f return f
def onReset(self, model=None, keep=False): def onReset(self, model=None, keep=False):
@ -96,7 +96,7 @@ class AddCards(QDialog):
except IndexError: except IndexError:
break break
self.editor.currentField = 0 self.editor.currentField = 0
self.editor.setNote(note) self.editor.setNote(note, focus=True)
def removeTempNote(self, note): def removeTempNote(self, note):
if not note or not note.id: if not note or not note.id:

View file

@ -538,7 +538,6 @@ class Editor(object):
def onUpdate(): def onUpdate():
self.stealFocus = True self.stealFocus = True
self.loadNote() self.loadNote()
self.stealFocus = False
self.checkValid() self.checkValid()
self.mw.progress.timer(100, onUpdate, False) self.mw.progress.timer(100, onUpdate, False)
else: else:
@ -584,6 +583,8 @@ class Editor(object):
self.note = note self.note = note
self.currentField = 0 self.currentField = 0
self.disableButtons() self.disableButtons()
if focus:
self.stealFocus = True
# change timer # change timer
if self.note: if self.note:
self.web.setHtml(_html % ( self.web.setHtml(_html % (
@ -617,6 +618,7 @@ class Editor(object):
self.widget.show() self.widget.show()
if self.stealFocus: if self.stealFocus:
self.web.setFocus() self.web.setFocus()
self.stealFocus = False
def focus(self): def focus(self):
self.web.setFocus() self.web.setFocus()