diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 0285692ab75e..e022294277fa 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -1203,15 +1203,24 @@ void ConnectionsDock::_slot_menu_about_to_popup() { } void ConnectionsDock::_tree_gui_input(const Ref &p_event) { - // Handle Delete press. - if (ED_IS_SHORTCUT("connections_editor/disconnect", p_event)) { - TreeItem *item = tree->get_selected(); - if (item && _get_item_type(*item) == TREE_ITEM_TYPE_CONNECTION) { - Connection connection = item->get_metadata(0); - _disconnect(connection); - update_tree(); + const Ref &key = p_event; + + if (key.is_valid() && key->is_pressed() && !key->is_echo()) { + if (ED_IS_SHORTCUT("connections_editor/disconnect", p_event)) { + TreeItem *item = tree->get_selected(); + if (item && _get_item_type(*item) == TREE_ITEM_TYPE_CONNECTION) { + Connection connection = item->get_metadata(0); + _disconnect(connection); + update_tree(); + + // Stop the Delete input from propagating elsewhere. + accept_event(); + return; + } + } else if (ED_IS_SHORTCUT("editor/open_search", p_event)) { + search_box->grab_focus(); + search_box->select_all(); - // Stop the Delete input from propagating elsewhere. accept_event(); return; } @@ -1219,42 +1228,41 @@ void ConnectionsDock::_tree_gui_input(const Ref &p_event) { // Handle RMB press. const Ref &mb_event = p_event; - if (mb_event.is_null() || !mb_event->is_pressed() || mb_event->get_button_index() != MouseButton::RIGHT) { - return; - } - TreeItem *item = tree->get_item_at_position(mb_event->get_position()); - if (!item) { - return; - } + if (mb_event.is_valid() && mb_event->is_pressed() && mb_event->get_button_index() == MouseButton::RIGHT) { + TreeItem *item = tree->get_item_at_position(mb_event->get_position()); + if (!item) { + return; + } - if (item->is_selectable(0)) { - // Update selection now, before `about_to_popup` signal. Needed for SIGNAL and CONNECTION context menus. - tree->set_selected(item); - } + if (item->is_selectable(0)) { + // Update selection now, before `about_to_popup` signal. Needed for SIGNAL and CONNECTION context menus. + tree->set_selected(item); + } - Vector2 screen_position = tree->get_screen_position() + mb_event->get_position(); + Vector2 screen_position = tree->get_screen_position() + mb_event->get_position(); - switch (_get_item_type(*item)) { - case TREE_ITEM_TYPE_ROOT: - break; - case TREE_ITEM_TYPE_CLASS: - class_menu_doc_class_name = item->get_metadata(0); - class_menu->set_position(screen_position); - class_menu->reset_size(); - class_menu->popup(); - accept_event(); // Don't collapse item. - break; - case TREE_ITEM_TYPE_SIGNAL: - signal_menu->set_position(screen_position); - signal_menu->reset_size(); - signal_menu->popup(); - break; - case TREE_ITEM_TYPE_CONNECTION: - slot_menu->set_position(screen_position); - slot_menu->reset_size(); - slot_menu->popup(); - break; + switch (_get_item_type(*item)) { + case TREE_ITEM_TYPE_ROOT: + break; + case TREE_ITEM_TYPE_CLASS: + class_menu_doc_class_name = item->get_metadata(0); + class_menu->set_position(screen_position); + class_menu->reset_size(); + class_menu->popup(); + accept_event(); // Don't collapse item. + break; + case TREE_ITEM_TYPE_SIGNAL: + signal_menu->set_position(screen_position); + signal_menu->reset_size(); + signal_menu->popup(); + break; + case TREE_ITEM_TYPE_CONNECTION: + slot_menu->set_position(screen_position); + slot_menu->reset_size(); + slot_menu->popup(); + break; + } } } diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 723a7c890177..ba7b627207d7 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -783,6 +783,9 @@ void GroupsEditor::_groups_gui_input(Ref p_event) { _menu_id_pressed(DELETE_GROUP); } else if (ED_IS_SHORTCUT("groups_editor/rename", p_event)) { _menu_id_pressed(RENAME_GROUP); + } else if (ED_IS_SHORTCUT("editor/open_search", p_event)) { + filter->grab_focus(); + filter->select_all(); } else { return; } diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index e1640af47bab..d5be2bd5a975 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -614,6 +614,26 @@ void InspectorDock::apply_script_properties(Object *p_object) { stored_properties.clear(); } +void InspectorDock::shortcut_input(const Ref &p_event) { + ERR_FAIL_COND(p_event.is_null()); + + Ref key = p_event; + + if (key.is_null() || !key->is_pressed() || key->is_echo()) { + return; + } + + if (!is_visible() || !inspector->get_rect().has_point(inspector->get_local_mouse_position())) { + return; + } + + if (ED_IS_SHORTCUT("editor/open_search", p_event)) { + search->grab_focus(); + search->select_all(); + accept_event(); + } +} + InspectorDock::InspectorDock(EditorData &p_editor_data) { singleton = this; set_name("Inspector"); @@ -770,6 +790,8 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { inspector->set_use_filter(true); // TODO: check me inspector->connect("resource_selected", callable_mp(this, &InspectorDock::_resource_selected)); + + set_process_shortcut_input(true); } InspectorDock::~InspectorDock() { diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 622a2521b314..1ad4b52b7d15 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -133,6 +133,8 @@ class InspectorDock : public VBoxContainer { void _select_history(int p_idx); void _prepare_history(); + virtual void shortcut_input(const Ref &p_event) override; + private: static InspectorDock *singleton; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 9c7ba827b775..4d998118e2fa 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -162,6 +162,20 @@ void SceneTreeDock::shortcut_input(const Ref &p_event) { accept_event(); } +void SceneTreeDock::_scene_tree_gui_input(Ref p_event) { + Ref key = p_event; + + if (key.is_null() || !key->is_pressed() || key->is_echo()) { + return; + } + + if (ED_IS_SHORTCUT("editor/open_search", p_event)) { + filter->grab_focus(); + filter->select_all(); + accept_event(); + } +} + void SceneTreeDock::instantiate(const String &p_file) { Vector scenes; scenes.push_back(p_file); @@ -4226,6 +4240,7 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec scene_tree->connect("script_dropped", callable_mp(this, &SceneTreeDock::_script_dropped)); scene_tree->connect("nodes_dragged", callable_mp(this, &SceneTreeDock::_nodes_drag_begin)); + scene_tree->get_scene_tree()->connect("gui_input", callable_mp(this, &SceneTreeDock::_scene_tree_gui_input)); scene_tree->get_scene_tree()->connect("item_icon_double_clicked", callable_mp(this, &SceneTreeDock::_focus_node)); editor_selection->connect("selection_changed", callable_mp(this, &SceneTreeDock::_selection_changed)); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index e765ef2a6b00..8b95cc02dd8f 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -235,6 +235,7 @@ class SceneTreeDock : public VBoxContainer { void _nodes_drag_begin(); virtual void input(const Ref &p_event) override; virtual void shortcut_input(const Ref &p_event) override; + void _scene_tree_gui_input(Ref p_event); void _new_scene_from(String p_file); void _set_node_owner_recursive(Node *p_node, Node *p_owner, const HashMap &p_inverse_duplimap);