mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
wait until saveNow() is done
fixes content missing if typed right before save, and add window complaining that fields aren't empty when they appear so
This commit is contained in:
parent
44457e78d2
commit
3fa597ed1a
1 changed files with 14 additions and 3 deletions
|
@ -79,6 +79,12 @@ function setFGButton(col) {
|
||||||
$("#forecolor")[0].style.backgroundColor = col;
|
$("#forecolor")[0].style.backgroundColor = col;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function saveNow() {
|
||||||
|
if (currentField) {
|
||||||
|
currentField.blur();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function onKey() {
|
function onKey() {
|
||||||
// esc clears focus, allowing dialog to close
|
// esc clears focus, allowing dialog to close
|
||||||
if (window.event.which == 27) {
|
if (window.event.which == 27) {
|
||||||
|
@ -581,9 +587,14 @@ class Editor(object):
|
||||||
return
|
return
|
||||||
self.saveTags()
|
self.saveTags()
|
||||||
# move focus out of fields and save tags
|
# move focus out of fields and save tags
|
||||||
self.parentWindow.setFocus()
|
self._saveNowWaiting = True
|
||||||
# and process events so any focus-lost hooks fire
|
self.web.evalWithCallback("saveNow()", self._saveNowDone)
|
||||||
self.mw.app.processEvents()
|
while self._saveNowWaiting:
|
||||||
|
# and process events so any focus-lost hooks fire
|
||||||
|
self.mw.app.processEvents()
|
||||||
|
|
||||||
|
def _saveNowDone(self, res):
|
||||||
|
self._saveNowWaiting = False
|
||||||
|
|
||||||
def checkValid(self):
|
def checkValid(self):
|
||||||
cols = []
|
cols = []
|
||||||
|
|
Loading…
Reference in a new issue