mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
fix changes made in Windows IME not being saved
https://anki.tenderapp.com/discussions/ankidesktop/28727-last-japanese-edit-in-a-field-doesnt-take-unless-enter-is-pressed-an-extra-time
This commit is contained in:
parent
a9f69b329f
commit
c3f3a996c5
1 changed files with 15 additions and 7 deletions
|
@ -28,6 +28,14 @@ function saveNow(keepFocus) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function triggerKeyTimer() {
|
||||||
|
clearChangeTimer();
|
||||||
|
changeTimer = setTimeout(function () {
|
||||||
|
updateButtonState();
|
||||||
|
saveField("key");
|
||||||
|
}, 600);
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -41,11 +49,7 @@ function onKey() {
|
||||||
focusPrevious();
|
focusPrevious();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearChangeTimer();
|
triggerKeyTimer();
|
||||||
changeTimer = setTimeout(function () {
|
|
||||||
updateButtonState();
|
|
||||||
saveField("key");
|
|
||||||
}, 600);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertNewline() {
|
function insertNewline() {
|
||||||
|
@ -82,10 +86,14 @@ function inPreEnvironment() {
|
||||||
return window.getComputedStyle(n).whiteSpace.startsWith("pre");
|
return window.getComputedStyle(n).whiteSpace.startsWith("pre");
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkForEmptyField() {
|
function onInput() {
|
||||||
|
// empty field?
|
||||||
if (currentField.innerHTML === "") {
|
if (currentField.innerHTML === "") {
|
||||||
currentField.innerHTML = "<br>";
|
currentField.innerHTML = "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure IME changes get saved
|
||||||
|
triggerKeyTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateButtonState() {
|
function updateButtonState() {
|
||||||
|
@ -288,7 +296,7 @@ function setFields(fields) {
|
||||||
f = "<br>";
|
f = "<br>";
|
||||||
}
|
}
|
||||||
txt += "<tr><td class=fname>{0}</td></tr><tr><td width=100%>".format(n);
|
txt += "<tr><td class=fname>{0}</td></tr><tr><td width=100%>".format(n);
|
||||||
txt += "<div id=f{0} onkeydown='onKey();' oninput='checkForEmptyField()' onmouseup='onKey();'".format(i);
|
txt += "<div id=f{0} onkeydown='onKey();' oninput='onInput()' onmouseup='onKey();'".format(i);
|
||||||
txt += " onfocus='onFocus(this);' onblur='onBlur();' class=field ";
|
txt += " onfocus='onFocus(this);' onblur='onBlur();' class=field ";
|
||||||
txt += "ondragover='onDragOver(this);' onpaste='onPaste(this);' ";
|
txt += "ondragover='onDragOver(this);' onpaste='onPaste(this);' ";
|
||||||
txt += "oncopy='onCutOrCopy(this);' oncut='onCutOrCopy(this);' ";
|
txt += "oncopy='onCutOrCopy(this);' oncut='onCutOrCopy(this);' ";
|
||||||
|
|
Loading…
Reference in a new issue