From ee39093ce3b1c54ec2397788307895c7c76ded91 Mon Sep 17 00:00:00 2001 From: Ed Swartz Date: Sun, 9 Feb 2020 08:48:35 -0600 Subject: [PATCH] Use left/right arrow to move cursor when unselecting in LineEdit -- useful for rename dialog (the filename portion is selected by default, and usually, want to change the end of the name, not the beginning) --- scene/gui/line_edit.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 2504989d2c5..4f44ad0c1b6 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -358,11 +358,20 @@ void LineEdit::_gui_input(Ref p_event) { FALLTHROUGH; } case KEY_LEFT: { - #ifndef APPLE_STYLE_KEYS - if (!k->get_alt()) + if (!k->get_alt()) { #endif + if (selection.enabled && !k->get_shift()) { + set_cursor_position(selection.begin); + deselect(); + handled = true; + break; + } + shift_selection_check_pre(k->get_shift()); +#ifndef APPLE_STYLE_KEYS + } +#endif #ifdef APPLE_STYLE_KEYS if (k->get_command()) { @@ -405,8 +414,20 @@ void LineEdit::_gui_input(Ref p_event) { FALLTHROUGH; } case KEY_RIGHT: { +#ifndef APPLE_STYLE_KEYS + if (!k->get_alt()) { +#endif + if (selection.enabled && !k->get_shift()) { + set_cursor_position(selection.end); + deselect(); + handled = true; + break; + } - shift_selection_check_pre(k->get_shift()); + shift_selection_check_pre(k->get_shift()); +#ifndef APPLE_STYLE_KEYS + } +#endif #ifdef APPLE_STYLE_KEYS if (k->get_command()) {