diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-06-07 16:25:43 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-06-13 06:16:03 +0200 |
commit | a272dffd15694fed53b615fb11a51159915d00f6 (patch) | |
tree | 916f88b57d965d47c4bd5a9bf7482099969889d9 /tests | |
parent | b16e7d2abcbb8558b5b4a85c7188c509bd7b9201 (diff) |
Take over touch grab after initial delayed mouse press from Flickable
It has always caused a lot of trouble that Flickable only knows how to
replay mouse events, not touch events, when pressDelay is set. Only the
press is delayed; then if some recipient grabs (e.g. by accepting the
mouse event), it grabs the underlying touch point ID, and thus the
following touch moves and release will be sent to it as QTouchEvents.
So, delegates in itemviews receive touch presses as mouse events, and
then touch events; and perhaps it's risky to assume that's all the same
sequence just because pressWasTouch got set to true, but now we do it
under either of two conditions: touch release occurs near the mouse
press, or the touch has been dragged past the drag threshold.
(The real fix is in Qt 6: Flickable knows how to replay touch events.)
Amends and extends 025f938c1b4676782674d54375e1e4e560e4b6cd and
fcc3d346c8aaff74b0054974040d3c1250301563
Task-number: QTBUG-77202
Fixes: QTBUG-104009
Change-Id: I7e1980e2fbc9b7a1b53c56409fb8a7adc424d61c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index e1e1ed97..bf65e486 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -923,4 +923,39 @@ TestCase { touch.release(0, control, x0 + data.dx2, y0 + data.dy2).commit() } + + Component { + id: listViewWithPressDelayAndSliders + ListView { + width: 300 + height: 500 + model: 3 + pressDelay: 150 + delegate: Slider { + width: 300 + height: 150 + } + } + } + + function test_listViewWithPressDelay() { + var listView = createTemporaryObject(listViewWithPressDelayAndSliders, testCase, { width: parent.width, height: parent.height }) + verify(listView) + var control = listView.itemAtIndex(0) + verify(control) + var movedSpy = signalSpy.createObject(control, {target: control, signalName: "moved"}) + verify(movedSpy.valid) + + var touch = touchEvent(control) + var x0 = control.handle.x + control.handle.width * 0.5 + var y0 = control.handle.y + control.handle.height * 0.5 + touch.press(0, control, x0, y0).commit() + tryCompare(control, "pressed", true) + fuzzyCompare(control.value, 0, 0.01) + + touch.move(0, control, x0 + 100, y0).commit() + tryVerify(function() { return (control.value > 0.3); }) // around 0.35, depending on style + tryVerify(function() { return (movedSpy.count > 0); }) // ideally == 1, but in Material and Fusion it's 2 + touch.release(0) + } } |