From 37ed8afb30a5106197ace61f220daecd64e8b288 Mon Sep 17 00:00:00 2001 From: stefnotch Date: Sat, 24 Apr 2021 10:19:20 +0200 Subject: [PATCH 1/2] Fix selecting and then pasting text Now the caret isn't off by 1 character anymore --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 2e4ef51e3..ac0b3b55f 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -504,9 +504,7 @@ namespace FlaxEngine.GUI if (string.IsNullOrEmpty(clipboardText)) return; - var right = SelectionRight; Insert(clipboardText); - SetSelection(Mathf.Max(right, 0) + clipboardText.Length); } /// @@ -626,7 +624,7 @@ namespace FlaxEngine.GUI _text = _text.Insert(left, str); - SetSelection(left + 1); + SetSelection(left + str.Length); } OnTextChanged(); From 3c2c95d670b0419f2b4b264d643ff30d386a9650 Mon Sep 17 00:00:00 2001 From: stefnotch Date: Sat, 24 Apr 2021 10:30:08 +0200 Subject: [PATCH 2/2] Fix textbox selection when deleting See https://forum.flaxengine.com/t/renaming-items-in-the-content-area-problem/334 --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index ac0b3b55f..e771adb8b 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -620,8 +620,10 @@ namespace FlaxEngine.GUI { var left = SelectionLeft >= 0 ? SelectionLeft : 0; if (HasSelection) + { _text = _text.Remove(left, selectionLength); - + SetSelection(left); + } _text = _text.Insert(left, str); SetSelection(left + str.Length);