diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-10-20 07:48:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 07:48:06 +0200 |
commit | 970d0d433b488c0ce832594721d82f58c73c032c (patch) | |
tree | 128c9d8186dcba70340485b87124a61c9081bc5f | |
parent | 5ddfc657abc4861b8102dc5c2a826d7f587c32e9 (diff) | |
parent | fbc095dc784925e3f9dbae406a62c007bff33e4d (diff) |
Merge pull request #42891 from gvaneyck/graph-begin-node-move-timing
Fix emit_signal timing for GraphEdit's begin/end node move
-rw-r--r-- | scene/gui/graph_edit.cpp | 10 | ||||
-rw-r--r-- | scene/gui/graph_edit.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index a7c15e7027..f779aca672 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -775,6 +775,11 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } if (mm.is_valid() && dragging) { + if (!moving_selection) { + emit_signal("_begin_node_move"); + moving_selection = true; + } + just_selected = true; drag_accum += mm->get_relative(); for (int i = get_child_count() - 1; i >= 0; i--) { @@ -881,16 +886,17 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } if (drag_accum != Vector2()) { - emit_signal("_begin_node_move"); - for (int i = get_child_count() - 1; i >= 0; i--) { GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (gn && gn->is_selected()) { gn->set_drag(false); } } + } + if (moving_selection) { emit_signal("_end_node_move"); + moving_selection = false; } dragging = false; diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index 37cb5989e9..d87bd41f27 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -98,6 +98,7 @@ private: bool dragging; bool just_selected; + bool moving_selection; Vector2 drag_accum; float zoom; |