From e76a9a51df5f78eaf12781bedf44df0b728c1c1b Mon Sep 17 00:00:00 2001 From: Maganty Rushyendra Date: Thu, 9 Jul 2020 17:47:22 +0800 Subject: [PATCH] Emit signals for GraphEdit multi-node selection and unselection Emit `node_selected` and `node_deselected` signals where appropriate when selecting or unselecting multiple GraphEdit nodes at once. (cherry picked from commit c1d5c7727cc9a537ec81f007be0b0987ccac91df) --- scene/gui/graph_edit.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 91f5af89631..490fd9b0e3f 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -849,10 +849,22 @@ void GraphEdit::_gui_input(const Ref &p_ev) { r.size *= zoom; bool in_box = r.intersects(box_selecting_rect); - if (in_box) + if (in_box) { + if (!gn->is_selected() && box_selection_mode_additive) { + emit_signal("node_selected", gn); + } else if (gn->is_selected() && !box_selection_mode_additive) { + emit_signal("node_unselected", gn); + } gn->set_selected(box_selection_mode_additive); - else - gn->set_selected(previus_selected.find(gn) != NULL); + } else { + bool select = (previus_selected.find(gn) != NULL); + if (gn->is_selected() && !select) { + emit_signal("node_unselected", gn); + } else if (!gn->is_selected() && select) { + emit_signal("node_selected", gn); + } + gn->set_selected(select); + } } top_layer->update(); @@ -870,7 +882,13 @@ void GraphEdit::_gui_input(const Ref &p_ev) { if (!gn) continue; - gn->set_selected(previus_selected.find(gn) != NULL); + bool select = (previus_selected.find(gn) != NULL); + if (gn->is_selected() && !select) { + emit_signal("node_unselected", gn); + } else if (!gn->is_selected() && select) { + emit_signal("node_selected", gn); + } + gn->set_selected(select); } top_layer->update(); } else { @@ -893,6 +911,7 @@ void GraphEdit::_gui_input(const Ref &p_ev) { Rect2 r = gn->get_rect(); r.size *= zoom; if (r.has_point(b->get_position())) { + emit_signal("node_unselected", gn); gn->set_selected(false); } }