diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2013-02-16 18:34:24 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-22 02:53:43 +0100 |
commit | e8ca72d484c0e56f030e4742bb5f92b6f0555146 (patch) | |
tree | 2b7c5a623af743d85fadd46855d9da9b0331320b /src | |
parent | 67db779665b1d95a20720c0dee058c47f7df8726 (diff) |
Flickable shouldn't grab the mouse until it starts an effective move.
If the boundBehavior prevents the flickable from moving its content
item in response to a drag it shouldn't grab the mouse as that will
prevent a parent MouseArea or Flickable from handling the drag.
Task-number: 29718
Change-Id: Ief82ef7b898ea2581fd0b7e52548f451d887e2f1
Reviewed-by: Alan Alpert <aalpert@rim.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeflickable.cpp | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index edbd9782..c0c7b2a0 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -789,9 +789,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (q->yflick()) { int dy = int(event->pos().y() - pressPos.y()); + if (vData.dragStartOffset == 0) + vData.dragStartOffset = dy; if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - if (!vMoved) - vData.dragStartOffset = dy; qreal newY = dy + vData.pressPos - vData.dragStartOffset; const qreal minY = vData.dragMinBound; const qreal maxY = vData.dragMaxBound; @@ -799,31 +799,28 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent newY = minY + (newY - minY) / 2; if (newY < maxY && maxY - minY <= 0) newY = maxY + (newY - maxY) / 2; - if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newY > minY || newY < maxY)) { - rejectY = true; - if (newY < maxY) { - newY = maxY; - rejectY = false; - } - if (newY > minY) { - newY = minY; - rejectY = false; - } + if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && newY <= maxY) { + newY = maxY; + rejectY = vData.pressPos == maxY && dy < 0; + } + if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && newY >= minY) { + newY = minY; + rejectY = vData.pressPos == minY && dy > 0; } if (!rejectY && stealMouse && dy != 0) { vData.move.setValue(qRound(newY)); vMoved = true; } - if (qAbs(dy) > QApplication::startDragDistance()) + if (!rejectY && qAbs(dy) > QApplication::startDragDistance()) stealY = true; } } if (q->xflick()) { int dx = int(event->pos().x() - pressPos.x()); + if (hData.dragStartOffset == 0) + hData.dragStartOffset = dx; if (qAbs(dx) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - if (!hMoved) - hData.dragStartOffset = dx; qreal newX = dx + hData.pressPos - hData.dragStartOffset; const qreal minX = hData.dragMinBound; const qreal maxX = hData.dragMaxBound; @@ -831,23 +828,20 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent newX = minX + (newX - minX) / 2; if (newX < maxX && maxX - minX <= 0) newX = maxX + (newX - maxX) / 2; - if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newX > minX || newX < maxX)) { - rejectX = true; - if (newX < maxX) { - newX = maxX; - rejectX = false; - } - if (newX > minX) { - newX = minX; - rejectX = false; - } + if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && newX <= maxX) { + newX = maxX; + rejectX = hData.pressPos == maxX && dx < 0; + } + if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && newX >= minX) { + newX = minX; + rejectX = hData.pressPos == minX && dx > 0; } if (!rejectX && stealMouse && dx != 0) { hData.move.setValue(qRound(newX)); hMoved = true; } - if (qAbs(dx) > QApplication::startDragDistance()) + if (!rejectX && qAbs(dx) > QApplication::startDragDistance()) stealX = true; } } |