diff options
author | Doris Verria <doris.verria@qt.io> | 2022-09-13 00:07:42 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-09-14 10:59:13 +0000 |
commit | abb77fe4d77b2a61c7167be55e25a6a78a26e876 (patch) | |
tree | eeb9c608d89e1b3eed9e659f4cf1f8616b288384 /examples/quickcontrols2/ios/todolist/ProjectPage.qml | |
parent | 7b3de2b885764f996912024c2f63d1a05f515bca (diff) |
todolist example: Make it easier to hide keyboard when finished editing
- Hide keyboard on Keys.onReturnPressed event in the TextField-s
- Add "Done" button to TextArea to mark editing as finished and hide
the keyboard in return
Done-with: Mitch Curtis <mitch.curtis@qt.io>
Change-Id: I3351e5b3db356946b59b19c6f424153cbf2dbbb1
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit db0716571c17a33809d9c4f53722fbc99656c0a4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/quickcontrols2/ios/todolist/ProjectPage.qml')
-rw-r--r-- | examples/quickcontrols2/ios/todolist/ProjectPage.qml | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/examples/quickcontrols2/ios/todolist/ProjectPage.qml b/examples/quickcontrols2/ios/todolist/ProjectPage.qml index ca86ea521a..fd33e73980 100644 --- a/examples/quickcontrols2/ios/todolist/ProjectPage.qml +++ b/examples/quickcontrols2/ios/todolist/ProjectPage.qml @@ -63,13 +63,14 @@ Page { TextArea { id: textArea leftPadding: 15 - rightPadding: 15 + rightPadding: doneButton.width bottomPadding: 10 topPadding: 10 font.pointSize: AppSettings.fontSize placeholderText: qsTr("Write a note...") text: root.projectNote wrapMode: TextArea.Wrap + clip: true Layout.fillWidth: true Layout.preferredHeight: 80 @@ -79,6 +80,16 @@ Page { Database.updateProjectNote(root.projectId, text) projectsModel.setProperty(projectIndex, "projectNote", textArea.text) } + + Button { + id: doneButton + text: qsTr("Done") + flat: true + visible: textArea.focus + onClicked: textArea.editingFinished() + anchors.right: parent.right + anchors.bottom: parent.bottom + } } ListView { @@ -186,6 +197,11 @@ Page { placeholderText: qsTr("Enter task name") font.pointSize: AppSettings.fontSize + Keys.onReturnPressed: { + if (addTaskButton.enabled) + addTaskButton.clicked() + } + Layout.fillWidth: true Layout.leftMargin: 10 Layout.rightMargin: 10 @@ -193,6 +209,7 @@ Page { } Button { + id: addTaskButton text: qsTr("Add task") flat: true font.pointSize: AppSettings.fontSize |