mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-08 02:58:19 +02:00
Merge pull request #4571 from huffman/select-all-edit
Add select all on focus behavior to entity properties window
This commit is contained in:
commit
b5f79c7e6e
1 changed files with 22 additions and 0 deletions
|
@ -477,6 +477,28 @@
|
||||||
ev.initEvent("change", true, true);
|
ev.initEvent("change", true, true);
|
||||||
document.activeElement.dispatchEvent(ev);
|
document.activeElement.dispatchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For input and textarea elements, select all of the text on focus
|
||||||
|
// WebKit-based browsers, such as is used with QWebView, have a quirk
|
||||||
|
// where the mouseup event comes after the focus event, causing the
|
||||||
|
// text to be deselected immediately after selecting all of the text.
|
||||||
|
// To make this work we block the first mouseup event after the elements
|
||||||
|
// received focus. If we block all mouseup events the user will not
|
||||||
|
// be able to click within the selected text.
|
||||||
|
var els = document.querySelectorAll("input, textarea");
|
||||||
|
for (var i = 0; i < els.length; i++) {
|
||||||
|
var clicked = false;
|
||||||
|
els[i].onfocus = function() {
|
||||||
|
this.select();
|
||||||
|
clicked = false;
|
||||||
|
};
|
||||||
|
els[i].onmouseup = function(e) {
|
||||||
|
if (!clicked) {
|
||||||
|
e.preventDefault();
|
||||||
|
clicked = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in a new issue