diff options
author | Andrew den Exter <andrew.den.exter@qinetic.com.au> | 2015-03-10 11:59:23 +1000 |
---|---|---|
committer | Andrew den Exter <andrew.den.exter@qinetic.com.au> | 2015-03-19 05:40:37 +0000 |
commit | 4c22c0cec688655e77ecbf8829b1477d12a3c10b (patch) | |
tree | b1dfaa7c0722c9a51b7197de38c2fc105ad688d0 /src/quick/items/qquickflickable.cpp | |
parent | 6293efb101263473709f4e887aead798e247b95f (diff) |
Allow Flickable's grab to be stolen if dragging over bounds.
This allows a parent item to intercept a drag gesture in one direction
when the flickable has reached it's limit in that direction without
disabling the drag over bounds for drag gestures in the opposite
direction.
Change-Id: I6ac60113f150dbb8da42d9b5593325b04be166f5
Reviewed-by: Martin Jones <martin.jones@qinetic.com.au>
Diffstat (limited to 'src/quick/items/qquickflickable.cpp')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index a9396051ab..52142346ab 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1010,6 +1010,9 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp bool rejectY = false; bool rejectX = false; + bool keepY = q->yflick(); + bool keepX = q->xflick(); + bool stealY = false; bool stealX = false; if (eventType == QEvent::MouseMove) { @@ -1082,6 +1085,11 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp } if (!rejectY && overThreshold) stealY = true; + + if ((newY >= minY && vData.pressPos == minY && vData.move.value() == minY && dy > 0) + || (newY <= maxY && vData.pressPos == maxY && vData.move.value() == maxY && dy < 0)) { + keepY = false; + } } vData.previousDragDelta = dy; } @@ -1144,13 +1152,19 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp if (!rejectX && overThreshold) stealX = true; + + if ((newX >= minX && vData.pressPos == minX && vData.move.value() == minX && dx > 0) + || (newX <= maxX && vData.pressPos == maxX && vData.move.value() == maxX && dx < 0)) { + keepX = false; + } } hData.previousDragDelta = dx; } stealMouse = stealX || stealY; if (stealMouse) { - q->setKeepMouseGrab(true); + if ((stealX && keepX) || (stealY && keepY)) + q->setKeepMouseGrab(true); clearDelayedPress(); } |