From 9bf96613c1be7d4df7132a9c3c9ac1a8740f698f Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 3 Jul 2012 12:29:57 +1000 Subject: Allow mouse interaction with 0 opacity items. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't filter event delivery to items with 0 opacity, and update the documentation the for opacity, visible and enabled properties and how each affects event delivery. Task-number: QTBUG-19193 Change-Id: Id48e4af763c9a7bbcc13b303342d303155dcadc9 Reviewed-by: Jan-Arve Sæther Reviewed-by: Martin Jones --- tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp | 22 +++++++++++----------- tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp index 83c5b62ef8..badec53aee 100644 --- a/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp +++ b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp @@ -157,7 +157,7 @@ public: void reset() { acceptTouchEvents = acceptMouseEvents = true; setEnabled(true); - setOpacity(1.0); + setVisible(true); lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList());//CHECK_VALID @@ -456,7 +456,7 @@ void tst_qquickcanvas::touchEvent_propagation() QFETCH(bool, acceptTouchEvents); QFETCH(bool, acceptMouseEvents); QFETCH(bool, enableItem); - QFETCH(qreal, itemOpacity); + QFETCH(bool, showItem); QQuickCanvas *canvas = new QQuickCanvas; canvas->resize(250, 250); @@ -487,7 +487,7 @@ void tst_qquickcanvas::touchEvent_propagation() topItem->acceptTouchEvents = acceptTouchEvents; topItem->acceptMouseEvents = acceptMouseEvents; topItem->setEnabled(enableItem); - topItem->setOpacity(itemOpacity); + topItem->setVisible(showItem); // single touch to top item, should be received by middle item QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas); @@ -514,7 +514,7 @@ void tst_qquickcanvas::touchEvent_propagation() middleItem->acceptTouchEvents = acceptTouchEvents; middleItem->acceptMouseEvents = acceptMouseEvents; middleItem->setEnabled(enableItem); - middleItem->setOpacity(itemOpacity); + middleItem->setVisible(showItem); // touch top and middle items, bottom item should get all events QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) @@ -531,7 +531,7 @@ void tst_qquickcanvas::touchEvent_propagation() // disable bottom item as well bottomItem->acceptTouchEvents = acceptTouchEvents; bottomItem->setEnabled(enableItem); - bottomItem->setOpacity(itemOpacity); + bottomItem->setVisible(showItem); // no events should be received QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) @@ -549,10 +549,10 @@ void tst_qquickcanvas::touchEvent_propagation() // disable middle item, touch on top item middleItem->acceptTouchEvents = acceptTouchEvents; middleItem->setEnabled(enableItem); - middleItem->setOpacity(itemOpacity); + middleItem->setVisible(showItem); QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas); QTest::qWait(50); - if (!enableItem || itemOpacity == 0) { + if (!enableItem || !showItem) { // middle item is disabled or has 0 opacity, bottom item receives the event QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); @@ -579,11 +579,11 @@ void tst_qquickcanvas::touchEvent_propagation_data() QTest::addColumn("acceptTouchEvents"); QTest::addColumn("acceptMouseEvents"); QTest::addColumn("enableItem"); - QTest::addColumn("itemOpacity"); + QTest::addColumn("showItem"); - QTest::newRow("disable events") << false << false << true << 1.0; - QTest::newRow("disable item") << true << true << false << 1.0; - QTest::newRow("opacity of 0") << true << true << true << 0.0; + QTest::newRow("disable events") << false << false << true << true; + QTest::newRow("disable item") << true << true << false << true; + QTest::newRow("hide item") << true << true << true << false; } void tst_qquickcanvas::touchEvent_cancel() diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp index 0ebfa81201..12c1a03b3e 100644 --- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp +++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp @@ -345,9 +345,9 @@ void tst_QQuickDrag::active() evaluate(item, "Drag.active = true"); QCOMPARE(evaluate(item, "Drag.active"), true); QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); + QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); evaluate(item, "Drag.active = false"); dropTarget.setOpacity(1.0); -- cgit v1.2.3