aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-11-11 13:44:22 +0100
committerMitch Curtis <mitch.curtis@qt.io>2019-11-15 13:22:06 +0100
commit19976fd5db1f2fb4925831c5f7a708c090e4a70e (patch)
tree2b52581a4f2763e042fc96c4c6ad0adecc35ef15
parente350aa83978e4a142d1e7c6433dfe37ddb0e71a8 (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>
-rw-r--r--src/imports/controls/SwipeView.qml1
-rw-r--r--src/imports/controls/imagine/SwipeView.qml1
-rw-r--r--src/imports/controls/material/SwipeView.qml1
-rw-r--r--tests/auto/controls/data/tst_swipeview.qml49
4 files changed, 52 insertions, 0 deletions
diff --git a/src/imports/controls/SwipeView.qml b/src/imports/controls/SwipeView.qml
index ad242e1a..7722d258 100644
--- a/src/imports/controls/SwipeView.qml
+++ b/src/imports/controls/SwipeView.qml
@@ -50,6 +50,7 @@ T.SwipeView {
model: control.contentModel
interactive: control.interactive
currentIndex: control.currentIndex
+ focus: control.focus
spacing: control.spacing
orientation: control.orientation
diff --git a/src/imports/controls/imagine/SwipeView.qml b/src/imports/controls/imagine/SwipeView.qml
index 4998edb7..70d65fef 100644
--- a/src/imports/controls/imagine/SwipeView.qml
+++ b/src/imports/controls/imagine/SwipeView.qml
@@ -61,6 +61,7 @@ T.SwipeView {
model: control.contentModel
interactive: control.interactive
currentIndex: control.currentIndex
+ focus: control.focus
spacing: control.spacing
orientation: control.orientation
diff --git a/src/imports/controls/material/SwipeView.qml b/src/imports/controls/material/SwipeView.qml
index 12ea36ae..a84f16c5 100644
--- a/src/imports/controls/material/SwipeView.qml
+++ b/src/imports/controls/material/SwipeView.qml
@@ -50,6 +50,7 @@ T.SwipeView {
model: control.contentModel
interactive: control.interactive
currentIndex: control.currentIndex
+ focus: control.focus
spacing: control.spacing
orientation: control.orientation
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)
+ }
}