DragHandler::onDragChanged not reporting continously
-
When performing a drag in a QML widget that captures events using a DragHandler, (click and move the mouse), the action is not registered until dragging is finished (unclick the mouse).
Dragging should register intermediary movements (while you're moving the mouse).Video demonstrating this issue: https://gitlab.com/advanced-effects/Advanced-Effects/-/work_items/51#note_3556028185
Relevant code:
ApplicationCanvas { DragHandler { onGrabChanged: (transition, event) => appCanvas.onGrabChanged(transition, event) onCanceled: (event) => appCanvas.onCanceled(event) }Code receiving input: https://gitlab.com/advanced-effects/Advanced-Effects/-/blob/main/src/canvas/view/viewlayers/selection_viewlayer.cpp?ref_type=heads#L132
void SelectionViewLayer::on_grab_changed(QPointingDevice::GrabTransition transition, QEventPoint event) { cancel_user_selection_area(); if (toolCtx()->selectedTool != ToolIdentifier::selection) { selectedObjects()->clear_all_objects(); return; }; QRectF drag_area = interactable.get_normalized_drag_area(event); /* Middle man work .... */ // Finally update selection area m_user_selection_area = drag_area; update_selected_objects(m_user_selection_area); }; -
Thanks! I see now that
handlerPointhas no signals though, how am I supposed to signal when the position has changed?More generally, I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click, is there a way I can generalize all this? Perhaps tracking the mouse position + the clicks separately? (
HoverHandler+WheelHandler+Keys.onPressed?)You're welcome!
@kaixoo said in DragHandler::onDragChanged not reporting continously:
I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click
Set your
acceptedButtons: https://doc.qt.io/qt-6/qml-qtquick-draghandler.html#acceptedButtons-propI see now that
handlerPointhas no signals though, how am I supposed to signal when the position has changed?handlerPointis a value type, likedateorstring. The string doesn't emit a signal either when a character gets modified. Rather, the whole value gets updated.Putting these together:
DragHandler { acceptedButtons: Qt.MiddleButton onCentroidChanged: { if (active) console.log("Centroid moved to", centroid.position) } } -
If you want to react to a drag move, you need a signal handler on the
DragHandler'scentroid.positionChanged.
grabChangedis only emitted when starting or stopping a drag. -
Ohhh, I see. Thank you!
Where iscentroiddocumented btw? It's only mentioned 3 times inDragHandler's doc page and only with some code examples, without showing a reference for the full type.@kaixoo said in DragHandler::onDragChanged not reporting continously:
Where is
centroiddocumented btw? It's only mentioned 3 times inDragHandler's doc page and only with some code examples, without showing a reference for the full type.The full type is https://doc.qt.io/qt-6/qml-qtquick-handlerpoint.html
centroidis inherited fromMultiPointHandler: https://doc.qt.io/qt-6/qml-qtquick-multipointhandler.html#centroid-propTo navigate there from the
DragHandlerdoc page, click on "List of all members, including inherited members" which goes to see https://doc.qt.io/qt-6/qml-qtquick-draghandler-members.html -
K kaixoo has marked this topic as solved
-
Thanks! I see now that
handlerPointhas no signals though, how am I supposed to signal when the position has changed?More generally, I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click, is there a way I can generalize all this? Perhaps tracking the mouse position + the clicks separately? (
HoverHandler+WheelHandler+Keys.onPressed?) -
Thanks! I see now that
handlerPointhas no signals though, how am I supposed to signal when the position has changed?More generally, I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click, is there a way I can generalize all this? Perhaps tracking the mouse position + the clicks separately? (
HoverHandler+WheelHandler+Keys.onPressed?)You're welcome!
@kaixoo said in DragHandler::onDragChanged not reporting continously:
I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click
Set your
acceptedButtons: https://doc.qt.io/qt-6/qml-qtquick-draghandler.html#acceptedButtons-propI see now that
handlerPointhas no signals though, how am I supposed to signal when the position has changed?handlerPointis a value type, likedateorstring. The string doesn't emit a signal either when a character gets modified. Rather, the whole value gets updated.Putting these together:
DragHandler { acceptedButtons: Qt.MiddleButton onCentroidChanged: { if (active) console.log("Centroid moved to", centroid.position) } } -
K kaixoo has marked this topic as solved