Invisible items should not respond to touch events.
authorMichael Brasser <michael.brasser@nokia.com>
Wed, 28 Dec 2011 03:28:12 +0000 (13:28 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 28 Dec 2011 04:21:49 +0000 (05:21 +0100)
Task-number: QTBUG-23327
Change-Id: I959c9ba40e4ce3972fc3fde2f1c7e73615e78e2e
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
src/quick/items/qquickcanvas.cpp
tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp

index 5fd8f93..c827bfb 100644 (file)
@@ -1111,7 +1111,7 @@ bool QQuickCanvasPrivate::deliverTouchPoints(QQuickItem *item, QTouchEvent *even
     QList<QQuickItem *> children = itemPrivate->paintOrderChildItems();
     for (int ii = children.count() - 1; ii >= 0; --ii) {
         QQuickItem *child = children.at(ii);
-        if (!child->isEnabled())
+        if (!child->isEnabled() || !child->isVisible())
             continue;
         if (deliverTouchPoints(child, event, newPoints, acceptedNewPoints, updatedPoints))
             return true;
index 44d2776..2308250 100644 (file)
@@ -67,6 +67,7 @@ private slots:
     void nonOverlapping();
     void nested();
     void inFlickable();
+    void invisible();
 
 private:
     QQuickView *createAndShowView(const QString &file);
@@ -678,6 +679,33 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
     delete canvas;
 }
 
+// QTBUG-23327
+void tst_QQuickMultiPointTouchArea::invisible()
+{
+    QQuickView *canvas = createAndShowView("signalTest.qml");
+    QVERIFY(canvas->rootObject() != 0);
+
+    QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
+    QVERIFY(area != 0);
+
+    area->setVisible(false);
+
+    QPoint p1(20,100);
+    QPoint p2(40,100);
+
+    QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+    sequence.press(0, p1).press(1, p2).commit();
+
+    QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
+    QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+    QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+    QCOMPARE(area->property("touchCount").toInt(), 0);
+
+    delete canvas;
+}
+
+
 QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file)
 {
     QQuickView *canvas = new QQuickView(0);