summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2014-11-25 14:02:03 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2014-11-28 16:12:45 +0100
commitfbcc860f28bbd062855359c635dd67420d6e8c9e (patch)
tree583a3a999d2df9b741ddb54bdd0d1018c44e0c21
parent71314570d03631f50ab2c262011aba6a572d0ced (diff)
downloadqtquickcontrols-fbcc860f28bbd062855359c635dd67420d6e8c9e.tar.gz
Fix StackView focus handling
Make StackView a FocusScope so inner focus changes don't have undesired side effects in other parts of the application. Task-number: QTBUG-42506 Change-Id: I0d901083196cf90f236a24e1dcd2e91bd9f320db Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
-rw-r--r--src/controls/StackView.qml2
-rw-r--r--tests/auto/controls/controls.pro2
-rw-r--r--tests/auto/controls/data/tst_stackview.qml26
3 files changed, 28 insertions, 2 deletions
diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml
index bd9c4de9..002355dc 100644
--- a/src/controls/StackView.qml
+++ b/src/controls/StackView.qml
@@ -473,7 +473,7 @@ import QtQuick.Controls.Private 1.0
\endlist
*/
-Item {
+FocusScope {
id: root
/*! \qmlproperty int StackView::depth
diff --git a/tests/auto/controls/controls.pro b/tests/auto/controls/controls.pro
index c3f00094..6ba1e3ea 100644
--- a/tests/auto/controls/controls.pro
+++ b/tests/auto/controls/controls.pro
@@ -34,6 +34,8 @@ OTHER_FILES += \
$$PWD/data/tst_rowlayout.qml \
$$PWD/data/tst_gridlayout.qml \
$$PWD/data/tst_slider.qml \
+ $$PWD/data/tst_stack.qml \
+ $$PWD/data/tst_stackview.qml \
$$PWD/data/tst_statusbar.qml \
$$PWD/data/tst_switch.qml \
$$PWD/data/tst_tab.qml \
diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml
index 848be725..f574feed 100644
--- a/tests/auto/controls/data/tst_stackview.qml
+++ b/tests/auto/controls/data/tst_stackview.qml
@@ -46,10 +46,12 @@ TestCase {
id: testCase
name: "Tests_StackView"
when: windowShown
+ visible: true
width: 400
height: 400
Item { id: anItem }
+ TextField { id: textField }
Component {
id: pageComponent
Item {}
@@ -57,7 +59,7 @@ TestCase {
Component {
id: stackComponent
- StackView {}
+ StackView { anchors.fill: parent }
}
function test_stackview() {
@@ -73,5 +75,27 @@ TestCase {
verify (stack.depth === 1)
stack.push(pageComponent)
verify (stack.depth === 2)
+ stack.destroy()
+ }
+
+ function test_focus() {
+ var stack = stackComponent.createObject(testCase, {initialItem: anItem})
+ verify (stack !== null, "stackview created is null")
+ compare(stack.currentItem, anItem)
+
+ stack.forceActiveFocus()
+ verify(stack.activeFocus)
+
+ stack.push({item: textField, immediate: true})
+ compare(stack.currentItem, textField)
+ textField.forceActiveFocus()
+ verify(textField.activeFocus)
+
+ stack.pop({immediate: true})
+ compare(stack.currentItem, anItem)
+ verify(stack.activeFocus)
+ verify(!textField.activeFocus)
+
+ stack.destroy()
}
}