From 690fd153567e176251068ddac2aa02ce270c1473 Mon Sep 17 00:00:00 2001 From: Robert Yevdokimov Date: Fri, 2 Feb 2024 09:03:38 -0500 Subject: [PATCH] Remove unnecessary focus methods and directly bind to 'set_close_on_escape' --- editor/input_event_configuration_dialog.cpp | 12 ++---------- editor/input_event_configuration_dialog.h | 1 - editor/project_settings_editor.cpp | 12 ++---------- editor/project_settings_editor.h | 3 --- 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp index 22673bec64f6..451829163cac 100644 --- a/editor/input_event_configuration_dialog.cpp +++ b/editor/input_event_configuration_dialog.cpp @@ -263,14 +263,6 @@ void InputEventConfigurationDialog::_on_listen_input_changed(const Refhas_focus()) { - set_close_on_escape(false); - } else { - set_close_on_escape(true); - } -} - void InputEventConfigurationDialog::_search_term_updated(const String &) { _update_input_list(); } @@ -656,8 +648,8 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { event_listener->set_h_size_flags(Control::SIZE_EXPAND_FILL); event_listener->set_stretch_ratio(0.75); event_listener->connect("event_changed", callable_mp(this, &InputEventConfigurationDialog::_on_listen_input_changed)); - event_listener->connect("focus_entered", callable_mp(this, &InputEventConfigurationDialog::_on_listen_focus_changed)); - event_listener->connect("focus_exited", callable_mp(this, &InputEventConfigurationDialog::_on_listen_focus_changed)); + event_listener->connect("focus_entered", callable_mp((AcceptDialog *)this, &AcceptDialog::set_close_on_escape).bind(false)); + event_listener->connect("focus_exited", callable_mp((AcceptDialog *)this, &AcceptDialog::set_close_on_escape).bind(true)); main_vbox->add_child(event_listener); main_vbox->add_child(memnew(HSeparator)); diff --git a/editor/input_event_configuration_dialog.h b/editor/input_event_configuration_dialog.h index 3ef089be8bc2..1d2cc8ba3605 100644 --- a/editor/input_event_configuration_dialog.h +++ b/editor/input_event_configuration_dialog.h @@ -104,7 +104,6 @@ class InputEventConfigurationDialog : public ConfirmationDialog { void _set_event(const Ref &p_event, const Ref &p_original_event, bool p_update_input_list_selection = true); void _on_listen_input_changed(const Ref &p_event); - void _on_listen_focus_changed(); void _search_term_updated(const String &p_term); void _update_input_list(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index e59bb76ff432..1b2b79527d1c 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -575,14 +575,6 @@ void ProjectSettingsEditor::_update_theme() { } } -void ProjectSettingsEditor::_input_filter_focused() { - set_close_on_escape(false); -} - -void ProjectSettingsEditor::_input_filter_unfocused() { - set_close_on_escape(true); -} - void ProjectSettingsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { @@ -715,8 +707,8 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { action_map_editor->connect("action_removed", callable_mp(this, &ProjectSettingsEditor::_action_removed)); action_map_editor->connect("action_renamed", callable_mp(this, &ProjectSettingsEditor::_action_renamed)); action_map_editor->connect("action_reordered", callable_mp(this, &ProjectSettingsEditor::_action_reordered)); - action_map_editor->connect(SNAME("filter_focused"), callable_mp(this, &ProjectSettingsEditor::_input_filter_focused)); - action_map_editor->connect(SNAME("filter_unfocused"), callable_mp(this, &ProjectSettingsEditor::_input_filter_unfocused)); + action_map_editor->connect(SNAME("filter_focused"), callable_mp((AcceptDialog *)this, &AcceptDialog::set_close_on_escape).bind(false)); + action_map_editor->connect(SNAME("filter_unfocused"), callable_mp((AcceptDialog *)this, &AcceptDialog::set_close_on_escape).bind(true)); tab_container->add_child(action_map_editor); localization_editor = memnew(LocalizationEditor); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 7771bdda619a..532820df5e8c 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -112,9 +112,6 @@ class ProjectSettingsEditor : public AcceptDialog { void _update_action_map_editor(); void _update_theme(); - void _input_filter_focused(); - void _input_filter_unfocused(); - protected: void _notification(int p_what); static void _bind_methods();