aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-07-04 15:18:04 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-07-04 18:05:37 +0000
commit64dd82cdeaf0a6ad10e0fb57a7dabe73ea9cb77e (patch)
tree780e3c0e22cd5cfcbb2e39c92e6a889507f52018
parentcce7cae5e464a34ecbacfa90f601a9b1dad712c3 (diff)
ScrollIndicator: 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-61785 Change-Id: I9a678570bfdd104ae32b4040ecef7625dcfd1aee Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickscrollindicator.cpp7
-rw-r--r--src/quicktemplates2/qquickscrollindicator_p.h4
-rw-r--r--tests/auto/controls/data/tst_scrollindicator.qml27
3 files changed, 38 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp
index 347c2a68..780eff1e 100644
--- a/src/quicktemplates2/qquickscrollindicator.cpp
+++ b/src/quicktemplates2/qquickscrollindicator.cpp
@@ -535,6 +535,13 @@ void QQuickScrollIndicatorAttached::setVertical(QQuickScrollIndicator *vertical)
emit verticalChanged();
}
+#if QT_CONFIG(quicktemplates2_multitouch)
+void QQuickScrollIndicator::touchEvent(QTouchEvent *event)
+{
+ event->ignore(); // QTBUG-61785
+}
+#endif
+
#if QT_CONFIG(accessibility)
QAccessible::Role QQuickScrollIndicator::accessibleRole() const
{
diff --git a/src/quicktemplates2/qquickscrollindicator_p.h b/src/quicktemplates2/qquickscrollindicator_p.h
index bc6c5418..476a7859 100644
--- a/src/quicktemplates2/qquickscrollindicator_p.h
+++ b/src/quicktemplates2/qquickscrollindicator_p.h
@@ -89,6 +89,10 @@ Q_SIGNALS:
void orientationChanged();
protected:
+#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_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml
index 54cd7159..894a035d 100644
--- a/tests/auto/controls/data/tst_scrollindicator.qml
+++ b/tests/auto/controls/data/tst_scrollindicator.qml
@@ -66,6 +66,11 @@ TestCase {
}
Component {
+ id: mouseArea
+ MouseArea { }
+ }
+
+ Component {
id: flickable
Flickable {
width: 100
@@ -217,4 +222,26 @@ TestCase {
compare(horizontal.contentItem.x, horizontal.leftPadding + 0.8 * horizontal.availableWidth)
compare(horizontal.contentItem.width, 0.2 * horizontal.availableWidth)
}
+
+ // QTBUG-61785
+ function test_mouseArea() {
+ var ma = createTemporaryObject(mouseArea, testCase, {width: testCase.width, height: testCase.height})
+ verify(ma)
+
+ var control = scrollIndicator.createObject(ma, {active: true, size: 0.9, 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)
+ }
}