From d1706827085d648ccef13e1df74796f19d455e89 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Dec 2017 10:33:50 +0100 Subject: StackView: don't block touch Unlike with mouse events there's setAcceptedMouseButtons(), currently there's no way to control whether a control receives touch events or not. As a temporary workaround until QQuickItem::setAcceptTouchEvents() has been added, we'll have to ignore touch events by hand. Task-number: QTBUG-65084 Change-Id: I3d51bdc80981557399f3bdfd181e359679cd1c20 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickstackview.cpp | 7 +++++++ src/quicktemplates2/qquickstackview_p.h | 4 ++++ tests/auto/controls/data/tst_stackview.qml | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp index 20e3c817..df67da87 100644 --- a/src/quicktemplates2/qquickstackview.cpp +++ b/src/quicktemplates2/qquickstackview.cpp @@ -1035,6 +1035,13 @@ bool QQuickStackView::childMouseEventFilter(QQuickItem *item, QEvent *event) return window && !window->mouseGrabberItem(); } +#if QT_CONFIG(quicktemplates2_multitouch) +void QQuickStackView::touchEvent(QTouchEvent *event) +{ + event->ignore(); // QTBUG-65084 +} +#endif + #if QT_CONFIG(accessibility) QAccessible::Role QQuickStackView::accessibleRole() const { diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h index ff115416..645223fd 100644 --- a/src/quicktemplates2/qquickstackview_p.h +++ b/src/quicktemplates2/qquickstackview_p.h @@ -153,6 +153,10 @@ protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; bool childMouseEventFilter(QQuickItem *, QEvent *) override; +#if QT_CONFIG(quicktemplates2_multitouch) + void touchEvent(QTouchEvent *event) override; +#endif + #if QT_CONFIG(accessibility) QAccessible::Role accessibleRole() const override; #endif diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index 1b421b4f..1bbdc2c3 100644 --- a/tests/auto/controls/data/tst_stackview.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -1137,4 +1137,26 @@ TestCase { compare(control.depth, 1) verify(item) } + + // QTBUG-65084 + function test_mouseArea() { + var ma = createTemporaryObject(mouseArea, testCase, {width: testCase.width, height: testCase.height}) + verify(ma) + + var control = stackView.createObject(ma, {width: testCase.width, height: testCase.height}) + verify(control) + + mousePress(control) + verify(ma.pressed) + + mouseRelease(control) + verify(!ma.pressed) + + var touch = touchEvent(control) + touch.press(0, control).commit() + verify(ma.pressed) + + touch.release(0, control).commit() + verify(!ma.pressed) + } } -- cgit v1.2.3