From a71749c8848762adf7c04eac7edef213183fbc6c Mon Sep 17 00:00:00 2001 From: Goldenlion5648 Date: Tue, 10 Mar 2026 18:54:11 -0400 Subject: [PATCH] Add enter and escape shortcuts in input map editor --- editor/settings/event_listener_line_edit.cpp | 2 +- .../input_event_configuration_dialog.cpp | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/editor/settings/event_listener_line_edit.cpp b/editor/settings/event_listener_line_edit.cpp index f5032877ad..5ec41c3ebf 100644 --- a/editor/settings/event_listener_line_edit.cpp +++ b/editor/settings/event_listener_line_edit.cpp @@ -190,7 +190,7 @@ void EventListenerLineEdit::gui_input(const Ref &p_event) { } accept_event(); - if (!event_to_check->is_pressed() || event_to_check->is_echo() || event_to_check->is_match(event) || !_is_event_allowed(event_to_check)) { + if (event_to_check.is_null() || !event_to_check->is_pressed() || event_to_check->is_echo() || event_to_check->is_match(event) || !_is_event_allowed(event_to_check)) { return; } diff --git a/editor/settings/input_event_configuration_dialog.cpp b/editor/settings/input_event_configuration_dialog.cpp index 5c79248383..194f963b17 100644 --- a/editor/settings/input_event_configuration_dialog.cpp +++ b/editor/settings/input_event_configuration_dialog.cpp @@ -44,8 +44,22 @@ void InputEventConfigurationDialog::_set_event(const Ref &p_event, const Ref &p_original_event, bool p_update_input_list_selection) { if (p_event.is_valid()) { - event = p_event; - original_event = p_original_event; + // If there is already a binding set, let enter or escape confirm/cancel the popup. + if (event.is_valid()) { + Ref current_key = p_event; + // Without this is_visible() check, the gui would not open if the already bound + // keybind was escape. + if (is_visible()) { + if (current_key->get_physical_keycode() == Key::ENTER) { + _ok_pressed(); + return; + } + if (current_key->get_physical_keycode() == Key::ESCAPE) { + _cancel_pressed(); + return; + } + } + } // If the event is changed to something which is not the same as the listener, // clear out the event from the listener text box to avoid confusion. @@ -53,7 +67,8 @@ void InputEventConfigurationDialog::_set_event(const Ref &p_event, c if (listener_event.is_valid() && !listener_event->is_match(p_event)) { event_listener->clear_event(); } - + event = p_event; + original_event = p_original_event; // Update Label event_as_text->set_text(EventListenerLineEdit::get_event_text(event, true));