on xenial help sign in
Autofocus first text field in every page of Welcome Wizard (#80)
bd11a94Miguel Gutiérrez
qml/Wizard/Page.qml+10
@@ -64,6 +64,10 @@ Item {
64 property bool lastPage: false
64 property bool lastPage: false
65 property bool buttonBarVisible: true
65 property bool buttonBarVisible: true
66
66
67+ // Item that will receive input focus when the page is in front
68+ // May be useful to open the keyboard automatically for a text field
69+ property Item focusItem
70+
67 property string title: ""
71 property string title: ""
68
72
69 signal backClicked()
73 signal backClicked()
@@ -71,6 +75,12 @@ Item {
71 visible: false
75 visible: false
72 anchors.fill: parent
76 anchors.fill: parent
73
77
78+ onVisibleChanged: {
79+ if (visible && focusItem) {
80+ focusItem.forceActiveFocus();
81+ }
82+ }
83+
74 Timer {
84 Timer {
75 id: indicatorTimer
85 id: indicatorTimer
76 interval: 1000
86 interval: 1000
qml/Wizard/Pages/50-timezone.qml+1−1
@@ -28,6 +28,7 @@ LocalComponents.Page {
28 objectName: "tzPage"
28 objectName: "tzPage"
29
29
30 title: i18n.tr("Time Zone")
30 title: i18n.tr("Time Zone")
31+ focusItem: searchField
31 forwardButtonSourceComponent: forwardButton
32 forwardButtonSourceComponent: forwardButton
32
33
33 property string selectedTimeZone: ""
34 property string selectedTimeZone: ""
@@ -91,7 +92,6 @@ LocalComponents.Page {
91 }
92 }
92
93
93 resetViews();
94 resetViews();
94− searchField.forceActiveFocus();
95 }
95 }
96 }
96 }
97
97
qml/Wizard/Pages/60-account.qml+1
@@ -22,6 +22,7 @@ import ".." as LocalComponents
22LocalComponents.Page {
22LocalComponents.Page {
23 objectName: "accountPage"
23 objectName: "accountPage"
24 title: i18n.tr("Personalize Your Device")
24 title: i18n.tr("Personalize Your Device")
25+ focusItem: nameInput
25
26
26 forwardButtonSourceComponent: forwardButton
27 forwardButtonSourceComponent: forwardButton
27 onlyOnInstall: true
28 onlyOnInstall: true
qml/Wizard/Pages/passcode-desktop.qml+1
@@ -29,6 +29,7 @@ LocalComponents.Page {
29 id: passwdSetPage
29 id: passwdSetPage
30 objectName: "passcodeDesktopPage"
30 objectName: "passcodeDesktopPage"
31 title: i18n.tr("Lock Screen Passcode")
31 title: i18n.tr("Lock Screen Passcode")
32+ focusItem: passwordField
32 forwardButtonSourceComponent: forwardButton
33 forwardButtonSourceComponent: forwardButton
33
34
34 readonly property alias password: passwordField.text
35 readonly property alias password: passwordField.text
qml/Wizard/Pages/password-set.qml+1
@@ -29,6 +29,7 @@ LocalComponents.Page {
29 id: passwdSetPage
29 id: passwdSetPage
30 objectName: "passwdSetPage"
30 objectName: "passwdSetPage"
31 title: i18n.tr("Lock Screen Password")
31 title: i18n.tr("Lock Screen Password")
32+ focusItem: passwordField
32 forwardButtonSourceComponent: forwardButton
33 forwardButtonSourceComponent: forwardButton
33
34
34 readonly property alias password: passwordField.text
35 readonly property alias password: passwordField.text