Skip to content

Commit

Permalink
[ui] Edge: Added child mouseArea to handle clicks
Browse files Browse the repository at this point in the history
Handling mouseClickEvent on QQuickItem was sometimes crashing when querying QMouseEvent::button(), adding a child mouse area to check if the pressed point exists on the edge to accept or reject an event seems like a better workaround and is stable
  • Loading branch information
waaake committed Jan 22, 2025
1 parent 9a582bb commit 5a116b4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions meshroom/ui/qml/GraphEditor/Edge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,28 @@ Item {
* account. */
curveScale = Qt.binding(() => cubic.ctrlPtDist / root.width) // Normalize by width
}

MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton

onPressed: function(mouse) {
if (edgeArea.containsPoint(Qt.point(mouse.x, mouse.y))) {
root.pressed(mouse);
}
else {
mouse.accepted = false;
}
}

onReleased: function(mouse) {
if (edgeArea.containsPoint(Qt.point(mouse.x, mouse.y))) {
root.released(mouse);
}
else {
mouse.accepted = false;
}
}
}
}
}

0 comments on commit 5a116b4

Please sign in to comment.