From e713273942c43faf8c8e25e16701a0b1ba8d8a46 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 24 Nov 2022 21:54:54 +0100 Subject: [PATCH] Fix textbox defocus on edit end #789 --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 340459c8f..69b4fa123 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -370,7 +370,7 @@ namespace FlaxEngine.GUI { Focus(); SetText(value); - Defocus(); + RemoveFocus(); } /// @@ -907,6 +907,14 @@ namespace FlaxEngine.GUI return HitTestText(location); } + private void RemoveFocus() + { + if (Parent != null) + Parent.Focus(); + else + Defocus(); + } + /// /// Calculates total text size. Called by to cache the text size. /// @@ -1297,7 +1305,7 @@ namespace FlaxEngine.GUI _text = _onStartEditValue; if (!IsNavFocused) - Defocus(); + RemoveFocus(); OnTextChanged(); return true; @@ -1311,7 +1319,7 @@ namespace FlaxEngine.GUI else if (!IsNavFocused) { // End editing - Defocus(); + RemoveFocus(); } return true; case KeyboardKeys.Home: