diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 969e2fd3a35..1e1d029b075 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -612,13 +612,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(); @@ -627,7 +621,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_position() + pos); @@ -641,19 +635,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 { @@ -668,6 +662,12 @@ void LineEdit::gui_input(const Ref &p_event) { return; } + Ref k = p_event; + + if (k.is_null()) { + return; + } + // Start Unicode input (hold). if (k->is_alt_pressed() && k->get_keycode() == Key::KP_ADD && !alt_start && !alt_start_no_hold) { if (selection.enabled) {