focus lost hook needs to be a filter

This commit is contained in:
Damien Elmes 2012-04-08 19:41:30 +09:00
parent 4bbd644e0a
commit e81cfc616f
2 changed files with 12 additions and 4 deletions

View file

@ -6,7 +6,7 @@ from aqt.qt import *
import re, os, sys, urllib2, ctypes, simplejson, traceback
from anki.utils import stripHTML, isWin, isMac, namedtmp
from anki.sound import play
from anki.hooks import runHook
from anki.hooks import runHook, runFilter
from aqt.sound import getAudio
from aqt.webview import AnkiWebView
from aqt.utils import shortcut, showInfo, showWarning, getBase, getFile, \
@ -399,7 +399,16 @@ class Editor(object):
if type == "blur":
if not self._keepButtons:
self.disableButtons()
runHook("editFocusLost", self.note)
# run any filters
if runFilter(
"editFocusLost", False, self.note, self.currentField):
# something updated the note; schedule reload
def onUpdate():
self.loadNote()
self.checkValid()
self.mw.progress.timer(100, onUpdate, False)
else:
self.checkValid()
else:
runHook("editTimer", self.note)
self.checkValid()

View file

@ -86,6 +86,5 @@ class ModelChooser(QHBoxLayout):
self.models.addItems([m['name'] for m in self._models])
for c, m in enumerate(self._models):
if m['id'] == self.deck.conf['curModel']:
print "current", c
self.models.setCurrentIndex(c)
break