diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index a56cfede34f..f177e634a62 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -74,6 +74,26 @@ static const char *_axis_names[JOY_AXIS_MAX * 2] = { "", " (R2)" }; +void ProjectSettingsEditor::_unhandled_input(const Ref &p_event) { + + const Ref k = p_event; + + if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) { + + if (k->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) { + if (search_button->is_pressed()) { + search_box->grab_focus(); + search_box->select_all(); + } else { + // This toggles the search bar display while giving the button its "pressed" appearance + search_button->set_pressed(true); + } + + accept_event(); + } + } +} + void ProjectSettingsEditor::_notification(int p_what) { switch (p_what) { @@ -116,6 +136,7 @@ void ProjectSettingsEditor::_notification(int p_what) { } break; case NOTIFICATION_POPUP_HIDE: { EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", get_rect()); + set_process_unhandled_input(false); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { search_button->set_icon(get_icon("Search", "EditorIcons")); @@ -800,6 +821,7 @@ void ProjectSettingsEditor::popup_project_settings() { _update_translations(); autoload_settings->update_autoload(); plugin_settings->update_plugins(); + set_process_unhandled_input(true); } void ProjectSettingsEditor::update_plugins() { @@ -1697,6 +1719,7 @@ void ProjectSettingsEditor::_editor_restart_close() { void ProjectSettingsEditor::_bind_methods() { + ClassDB::bind_method(D_METHOD("_unhandled_input"), &ProjectSettingsEditor::_unhandled_input); ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettingsEditor::_item_selected); ClassDB::bind_method(D_METHOD("_item_add"), &ProjectSettingsEditor::_item_add); ClassDB::bind_method(D_METHOD("_item_adds"), &ProjectSettingsEditor::_item_adds); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 4dfd8ba6023..c164b49d0e8 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -178,6 +178,7 @@ class ProjectSettingsEditor : public AcceptDialog { void _editor_restart_close(); protected: + void _unhandled_input(const Ref &p_event); void _notification(int p_what); static void _bind_methods(); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index c9c1f9c3e0c..f8425ebe227 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -140,32 +140,35 @@ void EditorSettingsDialog::_notification(int p_what) { void EditorSettingsDialog::_unhandled_input(const Ref &p_event) { - Ref k = p_event; + const Ref k = p_event; - if (k.is_valid() && is_window_modal_on_top()) { + if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) { - if (k->is_pressed()) { + bool handled = false; - bool handled = false; + if (ED_IS_SHORTCUT("editor/undo", p_event)) { + String action = undo_redo->get_current_action_name(); + if (action != "") + EditorNode::get_log()->add_message("Undo: " + action, EditorLog::MSG_TYPE_EDITOR); + undo_redo->undo(); + handled = true; + } - if (ED_IS_SHORTCUT("editor/undo", p_event)) { - String action = undo_redo->get_current_action_name(); - if (action != "") - EditorNode::get_log()->add_message("Undo: " + action, EditorLog::MSG_TYPE_EDITOR); - undo_redo->undo(); - handled = true; - } - if (ED_IS_SHORTCUT("editor/redo", p_event)) { - undo_redo->redo(); - String action = undo_redo->get_current_action_name(); - if (action != "") - EditorNode::get_log()->add_message("Redo: " + action, EditorLog::MSG_TYPE_EDITOR); - handled = true; - } + if (ED_IS_SHORTCUT("editor/redo", p_event)) { + undo_redo->redo(); + String action = undo_redo->get_current_action_name(); + if (action != "") + EditorNode::get_log()->add_message("Redo: " + action, EditorLog::MSG_TYPE_EDITOR); + handled = true; + } - if (handled) { - accept_event(); - } + if (k->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) { + _focus_current_search_box(); + handled = true; + } + + if (handled) { + accept_event(); } } } @@ -408,7 +411,6 @@ EditorSettingsDialog::EditorSettingsDialog() { tabs->set_tab_align(TabContainer::ALIGN_LEFT); tabs->connect("tab_changed", this, "_tabs_tab_changed"); add_child(tabs); - //set_child_rect(tabs); // General Tab @@ -425,7 +427,6 @@ EditorSettingsDialog::EditorSettingsDialog() { hbc->add_child(search_box); inspector = memnew(SectionedInspector); - //inspector->hide_top_label(); inspector->get_inspector()->set_use_filter(true); inspector->register_search_box(search_box); inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -474,7 +475,6 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcuts->set_v_size_flags(SIZE_EXPAND_FILL); shortcuts->set_columns(2); shortcuts->set_hide_root(true); - //shortcuts->set_hide_folding(true); shortcuts->set_column_titles_visible(true); shortcuts->set_column_title(0, TTR("Name")); shortcuts->set_column_title(1, TTR("Binding")); @@ -495,9 +495,7 @@ EditorSettingsDialog::EditorSettingsDialog() { press_a_key->connect("gui_input", this, "_wait_for_key"); press_a_key->connect("confirmed", this, "_press_a_key_confirm"); - //get_ok()->set_text("Apply"); set_hide_on_ok(true); - //get_cancel()->set_text("Close"); timer = memnew(Timer); timer->set_wait_time(1.5);