Focus current node after connecting

(cherry picked from commit d17c522991)
This commit is contained in:
kobewi 2021-10-21 15:58:07 +02:00 committed by Yuri Sizov
parent 3fd5fecfc1
commit ffc87b2bb1
3 changed files with 11 additions and 0 deletions

View File

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

View File

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

View File

@ -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 @@ protected:
public:
void set_node(Node *p_node);
void restore_last_valid_node();
void show_groups();
void show_connections();