on xenial help sign in
Autofocus first text field in every page of Welcome Wizard (#80)
commitbd11a94489465432d2cf12748d25a9e1c2940790 authorMiguel Gutiérrez <13243384+nikalon@users.noreply.github.com> dateMon 25 Feb 2019, 00:05 (8 years ago) parentcccfd09
5 files changed+14−1
qml/Wizard/Page.qml+10 qml/Wizard/Pages/50-timezone.qml+1−1 qml/Wizard/Pages/60-account.qml+1 qml/Wizard/Pages/passcode-desktop.qml+1 qml/Wizard/Pages/password-set.qml+1
qml/Wizard/Page.qml+10
@@ -64,6 +64,10 @@ Item {
6464 property bool lastPage: false
6565 property bool buttonBarVisible: true
6666
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+
6771 property string title: ""
6872
6973 signal backClicked()
@@ -71,6 +75,12 @@ Item {
7175 visible: false
7276 anchors.fill: parent
7377
78+ onVisibleChanged: {
79+ if (visible && focusItem) {
80+ focusItem.forceActiveFocus();
81+ }
82+ }
83+
7484 Timer {
7585 id: indicatorTimer
7686 interval: 1000
qml/Wizard/Pages/50-timezone.qml+1−1
@@ -28,6 +28,7 @@ LocalComponents.Page {
2828 objectName: "tzPage"
2929
3030 title: i18n.tr("Time Zone")
31+ focusItem: searchField
3132 forwardButtonSourceComponent: forwardButton
3233
3334 property string selectedTimeZone: ""
@@ -91,7 +92,6 @@ LocalComponents.Page {
9192 }
9293
9394 resetViews();
94− searchField.forceActiveFocus();
9595 }
9696 }
9797
qml/Wizard/Pages/60-account.qml+1
@@ -22,6 +22,7 @@ import ".." as LocalComponents
2222LocalComponents.Page {
2323 objectName: "accountPage"
2424 title: i18n.tr("Personalize Your Device")
25+ focusItem: nameInput
2526
2627 forwardButtonSourceComponent: forwardButton
2728 onlyOnInstall: true
qml/Wizard/Pages/passcode-desktop.qml+1
@@ -29,6 +29,7 @@ LocalComponents.Page {
2929 id: passwdSetPage
3030 objectName: "passcodeDesktopPage"
3131 title: i18n.tr("Lock Screen Passcode")
32+ focusItem: passwordField
3233 forwardButtonSourceComponent: forwardButton
3334
3435 readonly property alias password: passwordField.text
qml/Wizard/Pages/password-set.qml+1
@@ -29,6 +29,7 @@ LocalComponents.Page {
2929 id: passwdSetPage
3030 objectName: "passwdSetPage"
3131 title: i18n.tr("Lock Screen Password")
32+ focusItem: passwordField
3233 forwardButtonSourceComponent: forwardButton
3334
3435 readonly property alias password: passwordField.text