Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus current node after connecting #54071

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions editor/node_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions editor/node_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down