From c845859bc0f30ecd3212991f5316b4d852fc6edb Mon Sep 17 00:00:00 2001 From: Junsred <63877982+Junsred@users.noreply.github.com> Date: Thu, 28 Apr 2022 15:40:36 +0300 Subject: [PATCH 1/4] focus back to textInput after setting clipBoard --- src/lime/_internal/backend/html5/HTML5Window.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 850b13b06..29e39d602 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -925,6 +925,10 @@ class HTML5Window { Browser.document.execCommand("copy"); } + Timer.delay(function() + { + if (textInputEnabled) textInput.focus(); + }, 20); } public function setCursor(value:MouseCursor):MouseCursor From b3af18c3524ba5ee55a7cc648890bb4199f22554 Mon Sep 17 00:00:00 2001 From: Junsred <63877982+Junsred@users.noreply.github.com> Date: Fri, 29 Apr 2022 00:27:16 +0300 Subject: [PATCH 2/4] avoid duplicate code --- src/lime/_internal/backend/html5/HTML5Window.hx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 29e39d602..15cb7eb43 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -339,6 +339,13 @@ class HTML5Window public function focus():Void {} + public function focusTextInputWithDelay():Void { + Timer.delay(function() + { + if (textInputEnabled) textInput.focus(); + }, 20); + } + public function getCursor():MouseCursor { return cursor; @@ -457,10 +464,7 @@ class HTML5Window { if (event.relatedTarget == null || isDescendent(cast event.relatedTarget)) { - Timer.delay(function() - { - if (textInputEnabled) textInput.focus(); - }, 20); + focusTextInputWithDelay(); } } } @@ -925,10 +929,7 @@ class HTML5Window { Browser.document.execCommand("copy"); } - Timer.delay(function() - { - if (textInputEnabled) textInput.focus(); - }, 20); + focusTextInputWithDelay(); } public function setCursor(value:MouseCursor):MouseCursor From 4ce66f8d9493204065bd419dbed00069864f4960 Mon Sep 17 00:00:00 2001 From: Junsred <63877982+Junsred@users.noreply.github.com> Date: Fri, 29 Apr 2022 05:03:07 +0300 Subject: [PATCH 3/4] rename and check focus pending --- src/lime/_internal/backend/html5/HTML5Window.hx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 15cb7eb43..b01f0b9a9 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -75,6 +75,8 @@ class HTML5Window private var textInputEnabled:Bool; private var unusedTouchesPool = new List(); + private var __focusPending:Bool; + public function new(parent:Window) { this.parent = parent; @@ -339,9 +341,14 @@ class HTML5Window public function focus():Void {} - public function focusTextInputWithDelay():Void { + private function focusTextInput():Void + { + if (__focusPending) return; + __focusPending = true; + Timer.delay(function() { + __focusPending = false; if (textInputEnabled) textInput.focus(); }, 20); } @@ -464,7 +471,7 @@ class HTML5Window { if (event.relatedTarget == null || isDescendent(cast event.relatedTarget)) { - focusTextInputWithDelay(); + focusTextInput(); } } } @@ -929,7 +936,10 @@ class HTML5Window { Browser.document.execCommand("copy"); } - focusTextInputWithDelay(); + if (textInputEnabled) + { + focusTextInput(); + } } public function setCursor(value:MouseCursor):MouseCursor From 52bc8e40c94b2c39c0cf91dc43cfc5595db8c598 Mon Sep 17 00:00:00 2001 From: player-03 Date: Sat, 3 Sep 2022 15:41:18 -0400 Subject: [PATCH 4/4] Add explanatory comment. --- src/lime/_internal/backend/html5/HTML5Window.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index b01f0b9a9..37ee40767 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -343,6 +343,7 @@ class HTML5Window private function focusTextInput():Void { + // Avoid changing focus multiple times per frame. if (__focusPending) return; __focusPending = true;