aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2022-07-26 10:53:46 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-07-28 15:02:08 +0000
commitdb3c6f1238cb89056742bec5fd13e8e82c79b822 (patch)
treef2f4446998af31e3a922d0dd7ab27a962ba78cc7 /tests
parent7bf265c3495cd4b8c19dac80e6840d415a71058f (diff)
ScrollView: ignore filtered wheel events when wheelEnabled is false
The event filter was returning true when wheelEnabled was false, but wasn't ignoring the event, meaning that propagation of the wheel event stopped there, and items behind the ScrollView didn't get the event even if ScrollView wasn't using it. I'm not sure why it was done this way - the behavior isn't documented and no auto tests fail when changing it. Fixes: QTBUG-105164 Change-Id: Ie826ccfc406b77606ef0c6f043dc48f42a18cdc7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 7ef12715baf48912f713e6cb3ee2a784caaadaae) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_scrollview.qml46
1 files changed, 45 insertions, 1 deletions
diff --git a/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml b/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml
index 34ef866ca2..73332e0b4d 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_scrollview.qml
@@ -14,7 +14,7 @@ TestCase {
name: "ScrollView"
Component {
- id: signalSpy
+ id: signalSpyComponent
SignalSpy { }
}
@@ -534,4 +534,48 @@ TestCase {
verify(newHorizontalScrollBar.visible)
verify(!oldHorizontalScrollBar.visible)
}
+
+ Component {
+ id: mouseAreaWheelComponent
+
+ MouseArea {
+ anchors.fill: parent
+
+ property alias scrollView: scrollView
+ property alias flickable: flickable
+
+ ScrollView {
+ id: scrollView
+ anchors.fill: parent
+ wheelEnabled: false
+
+ Flickable {
+ id: flickable
+ contentHeight: 1000
+
+ Text {
+ text: "Test"
+ width: 500
+ height: 1000
+ }
+ }
+ }
+ }
+ }
+
+ // If a ScrollView containing a Flickable sets wheelEnabled to false,
+ // neither item should consume wheel events.
+ function test_wheelEnabled() {
+ let mouseArea = createTemporaryObject(mouseAreaWheelComponent, testCase)
+ verify(mouseArea)
+
+ let mouseWheelSpy = signalSpyComponent.createObject(mouseArea,
+ { target: mouseArea, signalName: "wheel" })
+ verify(mouseWheelSpy.valid)
+
+ let scrollView = mouseArea.scrollView
+ mouseWheel(scrollView, scrollView.width / 2, scrollView.height / 2, 0, 120)
+ compare(mouseWheelSpy.count, 1)
+ compare(mouseArea.flickable.contentY, 0)
+ }
}