From 5bbb15418f2a8793c9a4ffedc5a039f60094732a Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Thu, 18 Jun 2020 17:42:51 -0400 Subject: [PATCH] [3.2][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 --- scene/gui/line_edit.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 8211e1f679..d752979a11 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -285,6 +285,22 @@ void LineEdit::_gui_input(Ref 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;