diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 5541ee3e5..2e4ef51e3 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -812,6 +812,19 @@ namespace FlaxEngine.GUI return spaceLoc; } + private int FindPrevLineBegin() + { + int caretPos = CaretPosition; + if (caretPos - 2 < 0) + return 0; + int newLineLoc = _text.LastIndexOf('\n', caretPos - 2); + if (newLineLoc == -1) + newLineLoc = 0; + else + newLineLoc++; + return newLineLoc; + } + private int FindLineDownChar(int index) { if (!IsMultiline) @@ -1181,7 +1194,6 @@ namespace FlaxEngine.GUI return true; } case KeyboardKeys.Return: - { if (IsMultiline) { // Insert new line @@ -1192,15 +1204,22 @@ namespace FlaxEngine.GUI // End editing Defocus(); } - return true; - } case KeyboardKeys.Home: - { - // Move caret to the first character - SetSelection(0); + if (shiftDown) + { + // Select text from the current cursor point back to the beginning of the line + if (_selectionStart != -1) + { + SetSelection(FindPrevLineBegin(), _selectionStart); + } + } + else + { + // Move caret to the first character + SetSelection(0); + } return true; - } case KeyboardKeys.End: { // Move caret after last character