item->grabMouse();
item->grabTouchPoints(QVector<int>() << touchMouseId);
- q->sendEvent(item, mousePress.data());
+ QQuickItemPrivate::get(item)->deliverMouseEvent(mousePress.data());
event->setAccepted(mousePress->isAccepted());
if (!mousePress->isAccepted()) {
touchMouseId = -1;
if (mousePress->isAccepted() && checkIfDoubleClicked(event->timestamp())) {
QScopedPointer<QMouseEvent> mouseDoubleClick(touchToMouseEvent(QEvent::MouseButtonDblClick, p, event, item));
- q->sendEvent(item, mouseDoubleClick.data());
+ QQuickItemPrivate::get(item)->deliverMouseEvent(mouseDoubleClick.data());
event->setAccepted(mouseDoubleClick->isAccepted());
if (mouseDoubleClick->isAccepted()) {
return true;
if (p.state() & Qt::TouchPointMoved) {
if (mouseGrabberItem) {
QScopedPointer<QMouseEvent> me(touchToMouseEvent(QEvent::MouseMove, p, event, mouseGrabberItem));
- q->sendEvent(mouseGrabberItem, me.data());
+ QQuickItemPrivate::get(item)->deliverMouseEvent(me.data());
event->setAccepted(me->isAccepted());
if (me->isAccepted()) {
itemForTouchPointId[p.id()] = mouseGrabberItem; // N.B. the mouseGrabberItem may be different after returning from sendEvent()
touchMouseId = -1;
if (mouseGrabberItem) {
QScopedPointer<QMouseEvent> me(touchToMouseEvent(QEvent::MouseButtonRelease, p, event, mouseGrabberItem));
- q->sendEvent(mouseGrabberItem, me.data());
+ QQuickItemPrivate::get(item)->deliverMouseEvent(me.data());
if (mouseGrabberItem) // might have ungrabbed due to event
mouseGrabberItem->ungrabMouse();
return me->isAccepted();
void flickTwiceUsingTouches();
void nestedStopAtBounds();
void nestedStopAtBounds_data();
+ void nestedMouseAreaUsingTouch();
private:
- void flickWithTouch(QWindow *window, QTouchDevice *touchDevice);
+ void flickWithTouch(QWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to);
QQmlEngine engine;
};
QVERIFY(flickable != 0);
QCOMPARE(flickable->contentY(), 0.0f);
- flickWithTouch(window, touchDevice);
+ flickWithTouch(window, touchDevice, QPoint(100, 400), QPoint(100, 240));
qreal contentYAfterFirstFlick = flickable->contentY();
qDebug() << "contentYAfterFirstFlick " << contentYAfterFirstFlick;
QVERIFY(contentYAfterFirstFlick > 50.0f);
- flickWithTouch(window, touchDevice);
+ flickWithTouch(window, touchDevice, QPoint(100, 400), QPoint(100, 240));
// In the original bug, that second flick would cause Flickable to halt immediately
qreal contentYAfterSecondFlick = flickable->contentY();
delete window;
}
-void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDevice)
+void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to)
{
QTest::touchEvent(window, touchDevice)
- .press(0, QPoint(100, 400), window);
- QTest::qWait(1);
- QTest::touchEvent(window, touchDevice)
- .move(0, QPoint(100, 380), window);
- QTest::qWait(1);
- QTest::touchEvent(window, touchDevice)
- .move(0, QPoint(100, 360), window);
- QTest::qWait(1);
- QTest::touchEvent(window, touchDevice)
- .move(0, QPoint(100, 340), window);
- QTest::qWait(1);
- QTest::touchEvent(window, touchDevice)
- .move(0, QPoint(100, 320), window);
- QTest::qWait(1);
- QTest::touchEvent(window, touchDevice)
- .move(0, QPoint(100, 300), window);
- QTest::qWait(1);
- QTest::touchEvent(window, touchDevice)
- .move(0, QPoint(100, 280), window);
- QTest::qWait(1);
- QTest::touchEvent(window, touchDevice)
- .move(0, QPoint(100, 260), window);
+ .press(0, from, window);
QTest::qWait(1);
+ QPoint diff = to - from;
+ for (int i = 1; i <= 8; ++i) {
+ QTest::touchEvent(window, touchDevice)
+ .move(0, from + i*diff/8, window);
+ QTest::qWait(1);
+ }
QTest::touchEvent(window, touchDevice)
- .release(0, QPoint(100, 240), window);
+ .release(0, to, window);
QTest::qWait(1);
}
QTRY_VERIFY(!outer->isMoving());
}
+void tst_qquickflickable::nestedMouseAreaUsingTouch()
+{
+ QTouchDevice *touchDevice = new QTouchDevice;
+ touchDevice->setName("Fake Touchscreen");
+ touchDevice->setType(QTouchDevice::TouchScreen);
+ touchDevice->setCapabilities(QTouchDevice::Position);
+ QWindowSystemInterface::registerTouchDevice(touchDevice);
+
+ QQuickView *window = new QQuickView;
+ window->setSource(testFileUrl("nestedmousearea.qml"));
+ window->show();
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable != 0);
+
+ QCOMPARE(flickable->contentY(), 50.0f);
+ flickWithTouch(window, touchDevice, QPoint(100, 300), QPoint(100, 200));
+
+ // flickable should not have moved
+ QCOMPARE(flickable->contentY(), 50.0);
+
+ // draggable item should have moved up
+ QQuickItem *nested = window->rootObject()->findChild<QQuickItem*>("nested");
+ QVERIFY(nested->y() < 100.0);
+
+ delete window;
+}
+
QTEST_MAIN(tst_qquickflickable)
#include "tst_qquickflickable.moc"
foreach (const QPoint &point, points) {
// check hover
QTest::mouseMove(window, point);
- QTest::qWait(10);
- QCOMPARE(mouseArea->property("containsMouse").toBool(), insideTarget);
+ QTRY_COMPARE(mouseArea->property("containsMouse").toBool(), insideTarget);
// check mouse press
QTest::mousePress(window, Qt::LeftButton, 0, point);
- QTest::qWait(10);
- QCOMPARE(mouseArea->property("pressed").toBool(), insideTarget);
+ QTRY_COMPARE(mouseArea->property("pressed").toBool(), insideTarget);
// check mouse release
QTest::mouseRelease(window, Qt::LeftButton, 0, point);
- QTest::qWait(10);
- QCOMPARE(mouseArea->property("pressed").toBool(), false);
+ QTRY_COMPARE(mouseArea->property("pressed").toBool(), false);
}
delete window;
QTest::mouseMove(&view, position);
axis += invert ? -threshold : threshold;
QTest::mouseMove(&view, position);
- QCOMPARE(outer->drag()->active(), false);
- QCOMPARE(inner->drag()->active(), true);
+ QTRY_COMPARE(outer->drag()->active(), false);
+ QTRY_COMPARE(inner->drag()->active(), true);
QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
}