diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-04-05 15:00:59 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-04-05 14:31:56 +0000 |
commit | 0c02691f7ba646e782b04347fde3d75f9582b317 (patch) | |
tree | dd8b7c690a86a03faaa0831dff934ee8629cc1dd /src/quick/handlers/qquickdraghandler.cpp | |
parent | aba6cea90e023c99ac55b0e8dcdeae0af8305ef2 (diff) |
If DragHandler is dragged within its margin, don't jump
Not being pressed inside the target is a necessary but not sufficient
reason to reset m_pressTargetPos to the center of the target. The
intention was rather to make the target jump into position when the
parent was a different item: e.g. if a Slider has a DragHandler whose
target is the slider's knob, you can start dragging anywhere on the
whole Slider but you want the knob to jump to the cursor position when
the drag begins.
While we're at it, both branches of the if in onGrabChanged()
are checking that target() isn't null, so we can move that check out.
Fixes: QTBUG-74966
Change-Id: I05be11d27422b070d941b9e43d4e1157e071c3a5
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickdraghandler.cpp')
-rw-r--r-- | src/quick/handlers/qquickdraghandler.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp index 48f0599284..e5531369cf 100644 --- a/src/quick/handlers/qquickdraghandler.cpp +++ b/src/quick/handlers/qquickdraghandler.cpp @@ -112,14 +112,13 @@ QPointF QQuickDragHandler::targetCentroidPosition() void QQuickDragHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point) { QQuickMultiPointHandler::onGrabChanged(grabber, transition, point); - if (grabber == this && transition == QQuickEventPoint::GrabExclusive) { + if (grabber == this && transition == QQuickEventPoint::GrabExclusive && target()) { // In case the grab got handed over from another grabber, we might not get the Press. if (!m_pressedInsideTarget) { - if (target()) + if (target() != parentItem()) m_pressTargetPos = QPointF(target()->width(), target()->height()) / 2; } else if (m_pressTargetPos.isNull()) { - if (target()) - m_pressTargetPos = targetCentroidPosition(); + m_pressTargetPos = targetCentroidPosition(); } } } |