diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2019-11-11 13:44:22 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2019-11-15 13:22:06 +0100 |
commit | 19976fd5db1f2fb4925831c5f7a708c090e4a70e (patch) | |
tree | 2b52581a4f2763e042fc96c4c6ad0adecc35ef15 /tests/auto/controls | |
parent | e350aa83978e4a142d1e7c6433dfe37ddb0e71a8 (diff) |
SwipeView: fix issue where child items couldn't get focus
Set the focus property of the contentItem (ListView) to the focus
property of the SwipeView itself.
Change-Id: Ic410f7fb8db9fbb758b956dfe07e1b4265f5f687
Fixes: QTBUG-62401
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/controls')
-rw-r--r-- | tests/auto/controls/data/tst_swipeview.qml | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml index 38af37f7..5775491c 100644 --- a/tests/auto/controls/data/tst_swipeview.qml +++ b/tests/auto/controls/data/tst_swipeview.qml @@ -574,4 +574,53 @@ TestCase { compare(control.itemAt(i).x, 0) } } + + Component { + id: focusSwipeViewComponent + + SwipeView { + id: swipeView + anchors.fill: parent + focus: true + + property int pressCount + property int releaseCount + property int rectanglePressCount + property int rectangleReleaseCount + + Rectangle { + focus: true + + Keys.onPressed: ++swipeView.rectanglePressCount + Keys.onReleased: ++swipeView.rectangleReleaseCount + } + + Keys.onPressed: ++pressCount + Keys.onReleased: ++releaseCount + } + } + + function test_focus() { + if (Qt.styleHints.tabFocusBehavior !== Qt.TabFocusAllControls) + skip("This platform only allows tab focus for text controls") + + var control = createTemporaryObject(focusSwipeViewComponent, testCase) + verify(control) + compare(control.focus, true) + compare(control.contentItem.focus, true) + compare(control.itemAt(0).focus, true) + compare(control.itemAt(0).activeFocus, true) + + keyPress(Qt.Key_A) + compare(control.pressCount, 1) + compare(control.releaseCount, 0) + compare(control.rectanglePressCount, 1) + compare(control.rectangleReleaseCount, 0) + + keyRelease(Qt.Key_A) + compare(control.pressCount, 1) + compare(control.releaseCount, 1) + compare(control.rectanglePressCount, 1) + compare(control.rectangleReleaseCount, 1) + } } |