From 1cbad83f83e19d8bf02a054293fca9547b62d019 Mon Sep 17 00:00:00 2001 From: Travis Lange Date: Tue, 10 Feb 2026 10:54:46 -0500 Subject: [PATCH] allow toggling line edit via action that isn't keyboard --- scene/gui/line_edit.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index b07fdf5c51..66f8fc398b 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -660,13 +660,7 @@ void LineEdit::gui_input(const Ref &p_event) { return; } - Ref k = p_event; - - if (k.is_null()) { - return; - } - - if (editable && !editing && k->is_action_pressed("ui_text_submit", false)) { + if (editable && !editing && p_event->is_action_pressed("ui_text_submit", false)) { edit(); emit_signal(SNAME("editing_toggled"), true); accept_event(); @@ -675,7 +669,7 @@ void LineEdit::gui_input(const Ref &p_event) { // Open context menu. if (context_menu_enabled) { - if (k->is_action("ui_menu", true)) { + if (p_event->is_action("ui_menu", true)) { _update_context_menu(); Point2 pos = Point2(get_caret_pixel_pos().x, (get_size().y + theme_cache.font->get_height(theme_cache.font_size)) / 2); menu->set_position(get_screen_transform().xform(pos)); @@ -689,19 +683,19 @@ void LineEdit::gui_input(const Ref &p_event) { } if (is_shortcut_keys_enabled()) { - if (k->is_action("ui_copy", true)) { + if (p_event->is_action("ui_copy", true)) { copy_text(); accept_event(); return; } - if (k->is_action("ui_text_select_all", true)) { + if (p_event->is_action("ui_text_select_all", true)) { select(); accept_event(); return; } - if (k->is_action("ui_cut", true)) { + if (p_event->is_action("ui_cut", true)) { if (editable) { cut_text(); } else { @@ -716,6 +710,12 @@ void LineEdit::gui_input(const Ref &p_event) { return; } + Ref k = p_event; + + if (k.is_null()) { + return; + } + // Start Unicode Alt input (hold). if (k->is_alt_pressed() && k->get_keycode() == Key::KP_ADD && !alt_start && !alt_start_no_hold) { if (selection.enabled) {