From 34facd87699c3a65b0b8bfbe1590dc339997d6a4 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 5 Sep 2024 18:54:03 -0500 Subject: [PATCH 1/2] Add Shift+End for textboxbase --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 95b49850b..c22899c7b 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -924,6 +924,19 @@ namespace FlaxEngine.GUI return newLineLoc; } + private int FindNextLineBegin() + { + int caretPos = CaretPosition; + if (caretPos + 2 > TextLength) + return TextLength; + int newLineLoc = _text.IndexOf('\n', caretPos + 2); + if (newLineLoc == -1) + newLineLoc = TextLength; + else + newLineLoc++; + return newLineLoc; + } + private int FindLineDownChar(int index) { if (!IsMultiline) @@ -1491,8 +1504,13 @@ namespace FlaxEngine.GUI return true; case KeyboardKeys.End: { + // Select text from the current cursor point to the beginning of a new line + if (shiftDown && _selectionStart != -1) + SetSelection(_selectionStart, FindNextLineBegin()); // Move caret after last character - SetSelection(TextLength); + else + SetSelection(TextLength); + return true; } case KeyboardKeys.Tab: From c844c6b7f007599d53b8e2c7ba509ff3a2ec0c3e Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 5 Sep 2024 20:51:27 -0500 Subject: [PATCH 2/2] Add page up and down in textboxbase --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index c22899c7b..55f810211 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -1436,6 +1436,30 @@ namespace FlaxEngine.GUI return true; } + case KeyboardKeys.PageDown: + { + if (IsScrollable && IsMultiline) + { + var location = GetCharPosition(_selectionStart, out var height); + var sizeHeight = Size.Y / height; + location.Y += height * (int)sizeHeight; + TargetViewOffset = Vector2.Clamp(new Float2(0, location.Y), Float2.Zero, TextSize - new Float2(0, Size.Y)); + SetSelection(HitTestText(location)); + } + return true; + } + case KeyboardKeys.PageUp: + { + if (IsScrollable && IsMultiline) + { + var location = GetCharPosition(_selectionStart, out var height); + var sizeHeight = Size.Y / height; + location.Y -= height * (int)sizeHeight; + TargetViewOffset = Vector2.Clamp(new Float2(0, location.Y), Float2.Zero, TextSize - new Float2(0, Size.Y)); + SetSelection(HitTestText(location)); + } + return true; + } case KeyboardKeys.Delete: { if (IsReadOnly)