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> Pick-to: 6.4 Change-Id: I3351e5b3db356946b59b19c6f424153cbf2dbbb1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
parent
8c6ff5a68d
commit
db0716571c
|
@ -127,6 +127,11 @@ Page {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: 10
|
Layout.leftMargin: 10
|
||||||
Layout.rightMargin: 10
|
Layout.rightMargin: 10
|
||||||
|
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
if (createProjectButton.enabled)
|
||||||
|
createProjectButton.clicked()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
|
|
@ -63,13 +63,14 @@ Page {
|
||||||
TextArea {
|
TextArea {
|
||||||
id: textArea
|
id: textArea
|
||||||
leftPadding: 15
|
leftPadding: 15
|
||||||
rightPadding: 15
|
rightPadding: doneButton.width
|
||||||
bottomPadding: 10
|
bottomPadding: 10
|
||||||
topPadding: 10
|
topPadding: 10
|
||||||
font.pointSize: AppSettings.fontSize
|
font.pointSize: AppSettings.fontSize
|
||||||
placeholderText: qsTr("Write a note...")
|
placeholderText: qsTr("Write a note...")
|
||||||
text: root.projectNote
|
text: root.projectNote
|
||||||
wrapMode: TextArea.Wrap
|
wrapMode: TextArea.Wrap
|
||||||
|
clip: true
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 80
|
Layout.preferredHeight: 80
|
||||||
|
@ -79,6 +80,16 @@ Page {
|
||||||
Database.updateProjectNote(root.projectId, text)
|
Database.updateProjectNote(root.projectId, text)
|
||||||
projectsModel.setProperty(projectIndex, "projectNote", textArea.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 {
|
ListView {
|
||||||
|
@ -186,6 +197,11 @@ Page {
|
||||||
placeholderText: qsTr("Enter task name")
|
placeholderText: qsTr("Enter task name")
|
||||||
font.pointSize: AppSettings.fontSize
|
font.pointSize: AppSettings.fontSize
|
||||||
|
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
if (addTaskButton.enabled)
|
||||||
|
addTaskButton.clicked()
|
||||||
|
}
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: 10
|
Layout.leftMargin: 10
|
||||||
Layout.rightMargin: 10
|
Layout.rightMargin: 10
|
||||||
|
@ -193,6 +209,7 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
id: addTaskButton
|
||||||
text: qsTr("Add task")
|
text: qsTr("Add task")
|
||||||
flat: true
|
flat: true
|
||||||
font.pointSize: AppSettings.fontSize
|
font.pointSize: AppSettings.fontSize
|
||||||
|
|
Loading…
Reference in New Issue