summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Mardegan <mardy@users.sourceforge.net>2017-11-18 21:48:08 +0200
committerAlberto Mardegan <mardy@users.sourceforge.net>2017-11-23 08:56:55 +0000
commit73d374b1aa8f59c624592880d2edbcf30c132fb5 (patch)
treef142d4dbedd2eadeedd80b77e10b83d6155c50ab
parentdf47fdb8563452a1e68d4ec6d7c6eb36e7a9d353 (diff)
downloadqtquickcontrols-73d374b1aa8f59c624592880d2edbcf30c132fb5.tar.gz
ScrollView: fix cyclic Tab navigation
The ScrollView is not a control widget, which should be included in the focus chain when the user presses the Tab key; instead, it's a container and as such it should not interfere with the navigation. We also modify TableView, because it derives from ScrollView but we want to keep its current behavior. Task-number: QTBUG-64596 Change-Id: Ibd7833603d38171693b2f34c5859e9c4615b8ed4 Reviewed-by: Liang Qi <liang.qi@qt.io>
-rw-r--r--src/controls/Private/BasicTableView.qml2
-rw-r--r--src/controls/ScrollView.qml2
-rw-r--r--tests/auto/controls/data/tst_scrollview.qml84
3 files changed, 87 insertions, 1 deletions
diff --git a/src/controls/Private/BasicTableView.qml b/src/controls/Private/BasicTableView.qml
index 66ad0d36..2557dca7 100644
--- a/src/controls/Private/BasicTableView.qml
+++ b/src/controls/Private/BasicTableView.qml
@@ -348,6 +348,8 @@ ScrollView {
}
}
+ activeFocusOnTab: true
+
implicitWidth: 200
implicitHeight: 150
diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml
index 3a7b031f..65ed54d7 100644
--- a/src/controls/ScrollView.qml
+++ b/src/controls/ScrollView.qml
@@ -191,7 +191,7 @@ FocusScope {
/*! \internal */
property Style __style: styleLoader.item
- activeFocusOnTab: true
+ activeFocusOnTab: false
onContentItemChanged: {
diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml
index 842fd6dc..42398115 100644
--- a/tests/auto/controls/data/tst_scrollview.qml
+++ b/tests/auto/controls/data/tst_scrollview.qml
@@ -139,6 +139,45 @@ TestCase {
}
}
+ Component {
+ id: tabNavigationComponent
+ ApplicationWindow {
+ property alias scrollView: view
+ property alias control1: text1
+ property alias control2: text2
+ property alias control3: button
+
+ width: 400
+ height: 300
+ visible: true
+ modality: Qt.WindowModal
+
+ ScrollView {
+ id: view
+ anchors { top: parent.top; left: parent.left; right: parent.right; bottom: button.top }
+ Column {
+ width: view.width
+ TextField {
+ id: text1
+ anchors { left: parent.left; right: parent.right }
+ height: 30
+ }
+ TextField {
+ id: text2
+ anchors { left: parent.left; right: parent.right }
+ height: 30
+ }
+ }
+ }
+
+ Button {
+ id: button
+ anchors.bottom: parent.bottom
+ text: "hi"
+ }
+ }
+ }
+
function test_dragFetchAppend() { // QTBUG-50795
var scrollView = dragFetchAppendComponent.createObject(container)
verify(scrollView !== null, "view created is null")
@@ -319,5 +358,50 @@ TestCase {
verify(!control.control3.activeFocus)
control.destroy()
}
+
+ function test_navigation_QTBUG_64596() {
+ if (Qt.styleHints.tabFocusBehavior != Qt.TabFocusAllControls)
+ skip("This function doesn't support NOT iterating all.")
+
+ var control = tabNavigationComponent.createObject(container)
+ verify(control)
+ waitForRendering(control.contentItem)
+
+ control.requestActivate()
+ control.control1.forceActiveFocus()
+ verify(control.control1.activeFocus)
+ verify(!control.control2.activeFocus)
+ verify(!control.control3.activeFocus)
+ keyPress(Qt.Key_Tab)
+ verify(!control.control1.activeFocus)
+ verify(control.control2.activeFocus)
+ verify(!control.control3.activeFocus)
+ keyPress(Qt.Key_Tab)
+ verify(!control.control1.activeFocus)
+ verify(!control.control2.activeFocus)
+ verify(control.control3.activeFocus)
+ keyPress(Qt.Key_Tab)
+ verify(control.control1.activeFocus)
+ verify(!control.control2.activeFocus)
+ verify(!control.control3.activeFocus)
+ // and backwards
+ keyPress(Qt.Key_Tab, Qt.ShiftModifier)
+ verify(!control.control1.activeFocus)
+ verify(!control.control2.activeFocus)
+ verify(control.control3.activeFocus)
+ keyPress(Qt.Key_Tab, Qt.ShiftModifier)
+ verify(!control.control1.activeFocus)
+ verify(control.control2.activeFocus)
+ verify(!control.control3.activeFocus)
+ keyPress(Qt.Key_Tab, Qt.ShiftModifier)
+ verify(control.control1.activeFocus)
+ verify(!control.control2.activeFocus)
+ verify(!control.control3.activeFocus)
+ keyPress(Qt.Key_Tab, Qt.ShiftModifier)
+ verify(!control.control1.activeFocus)
+ verify(!control.control2.activeFocus)
+ verify(control.control3.activeFocus)
+ control.destroy()
+ }
}
}