Fix stealing of text focus when user clicks outside parent element (close #695)
This commit is contained in:
@@ -10,6 +10,7 @@ import js.html.InputElement;
|
||||
import js.html.InputEvent;
|
||||
import js.html.LinkElement;
|
||||
import js.html.MouseEvent;
|
||||
import js.html.Node;
|
||||
import js.html.TouchEvent;
|
||||
import js.html.ClipboardEvent;
|
||||
import js.Browser;
|
||||
@@ -307,7 +308,15 @@ class HTML5Window {
|
||||
|
||||
if (enableTextEvents) {
|
||||
|
||||
Timer.delay (function () { textInput.focus (); }, 20);
|
||||
if (event.relatedTarget == null || isDescendent (cast event.relatedTarget)) {
|
||||
|
||||
Timer.delay (function () {
|
||||
|
||||
if (enableTextEvents) textInput.focus ();
|
||||
|
||||
}, 20);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -717,6 +726,27 @@ class HTML5Window {
|
||||
}
|
||||
|
||||
|
||||
private function isDescendent (node:Node):Bool {
|
||||
|
||||
if (node == element) return true;
|
||||
|
||||
while (node != null) {
|
||||
|
||||
if (node.parentNode == element) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function move (x:Int, y:Int):Void {
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user