From 6e08b61ecc4e1f2b31e05c0f82ffd3efe628dcbe Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:44:02 -0700 Subject: [PATCH] nodeview: prevent default behavior when items are attached Fixes buggy behavior when dropping attached nodes and moving the cursor --- app/widget/nodeview/nodeview.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index f11703822..c5bcb355a 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -451,8 +451,10 @@ void NodeView::mousePressEvent(QMouseEvent *event) } } - // Default QGraphicsView functionality (selecting, dragging, etc.) - super::mousePressEvent(event); + if (attached_items_.isEmpty()) { + // Default QGraphicsView functionality (selecting, dragging, etc.) + super::mousePressEvent(event); + } // For any selected item, store its position in case the user is dragging it somewhere else auto selected_items = scene_.GetSelectedItems(); @@ -473,7 +475,9 @@ void NodeView::mouseMoveEvent(QMouseEvent *event) return; } - super::mouseMoveEvent(event); + if (attached_items_.isEmpty()) { + super::mouseMoveEvent(event); + } // See if there are any items attached if (!attached_items_.isEmpty()) { @@ -560,6 +564,8 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event) Node *select_context = nullptr; QVector select_nodes; + bool had_attached_items = !attached_items_.isEmpty(); + if (!attached_items_.isEmpty()) { select_context = nullptr; @@ -643,7 +649,9 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event) Core::instance()->undo_stack()->pushIfHasChildren(command); - super::mouseReleaseEvent(event); + if (!had_attached_items) { + super::mouseReleaseEvent(event); + } if (select_context) { scene_.context_map().value(select_context)->Select(select_nodes);