From f00ee23b7a7996348d64cb4427234036b03517bc Mon Sep 17 00:00:00 2001 From: "Alfred R. Baudisch" Date: Sat, 23 Jul 2022 14:29:30 +0200 Subject: [PATCH] Script Editor: Don't switch to 2D/3D viewports when selecting nodes Selecting nodes in the Scene dock automatically switches to the relevant 2D or 3D viewport. This behavior can be annoying while using the Script Editor and wanting to inspect node properties, so it's now disabled by default when the Script Editor is active. This new behavior can be changed back to the previous auto-switching using the `text_editor/navigation/stay_in_script_editor_on_node_selected` editor setting. (cherry picked from commit c4433c37932aca14b45e76a0b3498561532a0055) --- editor/editor_node.cpp | 4 ++++ editor/editor_settings.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index bc396400120..c76b3504ae9 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2028,6 +2028,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { Object *prev_inspected_object = get_inspector()->get_edited_object(); bool disable_folding = bool(EDITOR_GET("interface/inspector/disable_folding")); + bool stay_in_script_editor_on_node_selected = bool(EDITOR_GET("text_editor/navigation/stay_in_script_editor_on_node_selected")); bool is_resource = current_obj->is_class("Resource"); bool is_node = current_obj->is_class("Node"); @@ -2066,6 +2067,9 @@ void EditorNode::_edit_current(bool p_skip_foreign) { node_dock->set_node(current_node); scene_tree_dock->set_selected(current_node); inspector_dock->update(current_node); + if (!inspector_only) { + inspector_only = stay_in_script_editor_on_node_selected && ScriptEditor::get_singleton()->is_visible_in_tree(); + } } else { node_dock->set_node(nullptr); scene_tree_dock->set_selected(nullptr); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 29663426e6c..9ca528f7695 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -439,6 +439,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { hints["text_editor/navigation/minimap_width"] = PropertyInfo(Variant::INT, "text_editor/navigation/minimap_width", PROPERTY_HINT_RANGE, "50,250,1"); _initial_set("text_editor/navigation/mouse_extra_buttons_navigate_history", true); _initial_set("text_editor/navigation/drag_and_drop_selection", true); + _initial_set("text_editor/navigation/stay_in_script_editor_on_node_selected", true); // Appearance _initial_set("text_editor/appearance/show_line_numbers", true);