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] 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