mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
fix select all flicker
This commit is contained in:
parent
aadf9e2f87
commit
fdeb092a8d
1 changed files with 9 additions and 8 deletions
|
@ -84,19 +84,20 @@ function clearChangeTimer() {
|
||||||
|
|
||||||
function onFocus(elem) {
|
function onFocus(elem) {
|
||||||
currentField = elem;
|
currentField = elem;
|
||||||
setTimeout(unfocusHack, 1);
|
// prevent webkit from highlighting the whole field
|
||||||
|
$(elem).css("-webkit-user-select", "none");
|
||||||
|
setTimeout(function () { unfocusHack() }, 1);
|
||||||
py.run("focus:" + currentField.id.substring(1));
|
py.run("focus:" + currentField.id.substring(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// tabbing into a new field highlights everything, which we don't want
|
// restore cursor
|
||||||
function unfocusHack() {
|
function unfocusHack() {
|
||||||
var s = document.getSelection();
|
$(currentField).css("-webkit-user-select", "text");
|
||||||
if (s.rangeCount) {
|
var r = document.createRange()
|
||||||
var r = s.getRangeAt(0);
|
r.selectNodeContents(currentField);
|
||||||
r.collapse();
|
r.collapse();
|
||||||
s.removeAllRanges();
|
var s = document.getSelection();
|
||||||
s.addRange(r);
|
s.addRange(r);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function onBlur() {
|
function onBlur() {
|
||||||
|
|
Loading…
Reference in a new issue