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 c4433c3793)
This commit is contained in:
Alfred R. Baudisch 2022-07-23 14:29:30 +02:00 committed by Rémi Verschelde
parent 44eca8ef24
commit f00ee23b7a
2 changed files with 5 additions and 0 deletions

View file

@ -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);

View file

@ -439,6 +439,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> 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);