mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
focus lost hook needs to be a filter
This commit is contained in:
parent
4bbd644e0a
commit
e81cfc616f
2 changed files with 12 additions and 4 deletions
|
@ -6,7 +6,7 @@ from aqt.qt import *
|
||||||
import re, os, sys, urllib2, ctypes, simplejson, traceback
|
import re, os, sys, urllib2, ctypes, simplejson, traceback
|
||||||
from anki.utils import stripHTML, isWin, isMac, namedtmp
|
from anki.utils import stripHTML, isWin, isMac, namedtmp
|
||||||
from anki.sound import play
|
from anki.sound import play
|
||||||
from anki.hooks import runHook
|
from anki.hooks import runHook, runFilter
|
||||||
from aqt.sound import getAudio
|
from aqt.sound import getAudio
|
||||||
from aqt.webview import AnkiWebView
|
from aqt.webview import AnkiWebView
|
||||||
from aqt.utils import shortcut, showInfo, showWarning, getBase, getFile, \
|
from aqt.utils import shortcut, showInfo, showWarning, getBase, getFile, \
|
||||||
|
@ -399,10 +399,19 @@ class Editor(object):
|
||||||
if type == "blur":
|
if type == "blur":
|
||||||
if not self._keepButtons:
|
if not self._keepButtons:
|
||||||
self.disableButtons()
|
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:
|
else:
|
||||||
runHook("editTimer", self.note)
|
runHook("editTimer", self.note)
|
||||||
self.checkValid()
|
self.checkValid()
|
||||||
# focused into field?
|
# focused into field?
|
||||||
elif str.startswith("focus"):
|
elif str.startswith("focus"):
|
||||||
(type, num) = str.split(":", 1)
|
(type, num) = str.split(":", 1)
|
||||||
|
|
|
@ -86,6 +86,5 @@ class ModelChooser(QHBoxLayout):
|
||||||
self.models.addItems([m['name'] for m in self._models])
|
self.models.addItems([m['name'] for m in self._models])
|
||||||
for c, m in enumerate(self._models):
|
for c, m in enumerate(self._models):
|
||||||
if m['id'] == self.deck.conf['curModel']:
|
if m['id'] == self.deck.conf['curModel']:
|
||||||
print "current", c
|
|
||||||
self.models.setCurrentIndex(c)
|
self.models.setCurrentIndex(c)
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue