Fix stealing of text focus when user clicks outside parent element (close #695)

This commit is contained in:
Joshua Granick
2018-02-15 23:35:48 -08:00
parent 453bc5bade
commit 6c7b0febae

View File

@@ -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 {