summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-06-19 13:19:39 +0200
committerGitHub <noreply@github.com>2020-06-19 13:19:39 +0200
commit1cd8e835be5b08e4c0be8b691e5c7fb9eb4d740a (patch)
tree0ab40e7e64c177b1616a04697ecf100dca745df1
parent3eab3c10b554013d4e37d1e9739bfff4e278acd0 (diff)
parent7433c9d40cc76d0891ab2c8f2296b1b9bdc883ac (diff)
Merge pull request #39659 from asmaloney/macos-command-backspace
[macOS] Command-backspace in line edit
-rw-r--r--scene/gui/line_edit.cpp16
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;