summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-10-10 10:50:20 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-10-13 13:01:46 +0200
commit6fd9e9164b0bd928bea1245f19cb67681b8dcbfb (patch)
treeba1df5749ade9f45fdcfb4df1dd82120db99862b /examples
parent35589b1f5a4e86856c7024bbfb067e0835c703f6 (diff)
downloadqtquickcontrols-6fd9e9164b0bd928bea1245f19cb67681b8dcbfb.tar.gz
Custom filled dialog example: handle back button to close
On Android, it should prefer to close the dialog rather than get stuck or exit the application. (It was already possible to close the dialog by tapping outside, though.) The back button can also be used on other platforms which have them (e.g. multimedia keyboards on desktop). Change-Id: I19d2ad62ff370fa467d80d51d73cb95fd5830bed Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/dialogs/systemdialogs/CustomDialogs.qml5
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/quick/dialogs/systemdialogs/CustomDialogs.qml b/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
index 405dece3..cc91fbb4 100644
--- a/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
+++ b/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
@@ -135,6 +135,7 @@ Item {
id: filledDialog
modality: dialogModal.checked ? Qt.WindowModal : Qt.NonModal
title: customizeTitle.checked ? windowTitleField.text : "Customized content"
+ onRejected: lastChosen.text = "Rejected"
contentItem: Rectangle {
color: "lightskyblue"
implicitWidth: 400
@@ -144,8 +145,8 @@ Item {
color: "navy"
anchors.centerIn: parent
}
- focus: true
- Keys.onEscapePressed: filledDialog.close()
+ Keys.onEscapePressed: filledDialog.reject()
+ Keys.onBackPressed: filledDialog.reject() // especially necessary on Android
}
}