From d17c522991159260b95621a45383fde408eb83c9 Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 21 Oct 2021 15:58:07 +0200 Subject: [PATCH] Focus current node after connecting --- editor/connections_dialog.cpp | 2 ++ editor/node_dock.cpp | 7 +++++++ editor/node_dock.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index c788fee7f8c4..e0310d8d65e3 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -39,6 +39,7 @@ #include "editor/editor_settings.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/scene_tree_editor.h" +#include "editor/node_dock.h" #include "editor/scene_tree_dock.h" #include "plugins/script_editor_plugin.h" #include "scene/gui/button.h" @@ -1440,6 +1441,7 @@ ConnectionsDock::ConnectionsDock() { connect_button->connect("pressed", callable_mp(this, &ConnectionsDock::_connect_pressed)); connect_dialog = memnew(ConnectDialog); + connect_dialog->connect("connected", callable_mp(NodeDock::get_singleton(), &NodeDock::restore_last_valid_node), CONNECT_DEFERRED); add_child(connect_dialog); disconnect_all_dialog = memnew(ConfirmationDialog); diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index 545769d32704..ebb35eedf9cc 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -70,6 +70,9 @@ void NodeDock::update_lists() { void NodeDock::set_node(Node *p_node) { connections->set_node(p_node); groups->set_current(p_node); + if (p_node) { + last_valid_node = p_node; + } if (p_node) { if (connections_button->is_pressed()) { @@ -88,6 +91,10 @@ void NodeDock::set_node(Node *p_node) { } } +void NodeDock::restore_last_valid_node() { + set_node(last_valid_node); +} + NodeDock::NodeDock() { singleton = this; diff --git a/editor/node_dock.h b/editor/node_dock.h index e9dcc41d48cb..cc221714530f 100644 --- a/editor/node_dock.h +++ b/editor/node_dock.h @@ -47,6 +47,7 @@ class NodeDock : public VBoxContainer { HBoxContainer *mode_hb = nullptr; Label *select_a_node = nullptr; + Node *last_valid_node = nullptr; private: static NodeDock *singleton; @@ -60,6 +61,7 @@ class NodeDock : public VBoxContainer { public: void set_node(Node *p_node); + void restore_last_valid_node(); void show_groups(); void show_connections();