Skip to content

Commit 2024774

Browse files
committed
Merge pull request godotengine#108996 from gtibo/graphnode-selection-fix
Update GraphNode selection logic if not visible
2 parents c5d2033 + 2aa7643 commit 2024774

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

scene/gui/graph_edit.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,12 @@ void GraphEdit::_graph_element_deselected(Node *p_node) {
587587
emit_signal(SNAME("node_deselected"), graph_element);
588588
}
589589

590+
void GraphEdit::_graph_element_visibility_changed(GraphElement *p_graph_element) {
591+
if (p_graph_element->is_selected() && !p_graph_element->is_visible()) {
592+
p_graph_element->set_selected(false);
593+
}
594+
}
595+
590596
void GraphEdit::_graph_element_resize_request(const Vector2 &p_new_minsize, Node *p_node) {
591597
GraphElement *graph_element = Object::cast_to<GraphElement>(p_node);
592598
ERR_FAIL_NULL(graph_element);
@@ -700,6 +706,7 @@ void GraphEdit::add_child_notify(Node *p_child) {
700706
graph_element->connect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_element_moved).bind(graph_element));
701707
graph_element->connect("node_selected", callable_mp(this, &GraphEdit::_graph_element_selected).bind(graph_element));
702708
graph_element->connect("node_deselected", callable_mp(this, &GraphEdit::_graph_element_deselected).bind(graph_element));
709+
graph_element->connect(SceneStringName(visibility_changed), callable_mp(this, &GraphEdit::_graph_element_visibility_changed).bind(graph_element));
703710

704711
GraphNode *graph_node = Object::cast_to<GraphNode>(graph_element);
705712
if (graph_node) {
@@ -756,6 +763,7 @@ void GraphEdit::remove_child_notify(Node *p_child) {
756763
graph_element->disconnect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_element_moved));
757764
graph_element->disconnect("node_selected", callable_mp(this, &GraphEdit::_graph_element_selected));
758765
graph_element->disconnect("node_deselected", callable_mp(this, &GraphEdit::_graph_element_deselected));
766+
graph_element->disconnect(SceneStringName(visibility_changed), callable_mp(this, &GraphEdit::_graph_element_visibility_changed));
759767

760768
GraphNode *graph_node = Object::cast_to<GraphNode>(graph_element);
761769
if (graph_node) {
@@ -2041,6 +2049,10 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
20412049
continue;
20422050
}
20432051

2052+
if (!graph_element->is_visible()) {
2053+
continue;
2054+
}
2055+
20442056
// Only select frames when the box selection is fully enclosing them.
20452057
bool is_frame = Object::cast_to<GraphFrame>(graph_element);
20462058
Rect2 r = graph_element->get_rect();
@@ -2174,6 +2186,10 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
21742186
continue;
21752187
}
21762188

2189+
if (!selected_element->is_visible()) {
2190+
continue;
2191+
}
2192+
21772193
if (selected_element->is_resizing()) {
21782194
continue;
21792195
}

scene/gui/graph_edit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ class GraphEdit : public Control {
322322

323323
void _graph_element_selected(Node *p_node);
324324
void _graph_element_deselected(Node *p_node);
325+
void _graph_element_visibility_changed(GraphElement *p_graph_element);
325326
void _graph_element_resize_request(const Vector2 &p_new_minsize, Node *p_node);
326327
void _graph_frame_autoshrink_changed(const Vector2 &p_new_minsize, GraphFrame *p_frame);
327328
void _graph_element_moved(Node *p_node);

0 commit comments

Comments
 (0)