diff options
author | Andy Maloney <asmaloney@gmail.com> | 2020-06-18 17:45:40 -0400 |
---|---|---|
committer | Andy Maloney <asmaloney@gmail.com> | 2020-06-18 17:45:40 -0400 |
commit | 7433c9d40cc76d0891ab2c8f2296b1b9bdc883ac (patch) | |
tree | 2cd34408781070ab0064ad1cd7cae15bd8b61b9f /scene/gui | |
parent | 4e0f31a67cb757f95a658a02ac28afcdda40b299 (diff) |
[macOS] Command-backspace in line edit
Make command-backspace in line edit work like other macOS applications.
If there is a selection, command-backspace deletes the selection.
If there isn't a selection, command-backspace deletes from the cursor to the beginning of the line edit.
This addresses part of godotengine/godot#23548
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/line_edit.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index ee6783167a..ba55927980 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -274,6 +274,22 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { set_cursor_position(text.length()); shift_selection_check_post(k->get_shift()); } break; + case (KEY_BACKSPACE): { + if (!editable) + break; + + // If selected, delete the selection + if (selection.enabled) { + selection_delete(); + break; + } + + // Otherwise delete from cursor to beginning of text edit + int current_pos = get_cursor_position(); + if (current_pos != 0) { + delete_text(0, current_pos); + } + } break; #endif default: { handled = false; |