summaryrefslogtreecommitdiffstats
path: root/demos/declarative/samegame/samegame.qml
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-06-03 06:27:47 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-06-03 06:53:11 (GMT)
commit939375996496a55a1bb424d6a328f47d2224ed51 (patch)
treee196085fb599e38fe6a19491500c33f8b9119a8c /demos/declarative/samegame/samegame.qml
parent26d65a844b20a0056820c15188532b3895a3e091 (diff)
downloadQt-939375996496a55a1bb424d6a328f47d2224ed51.zip
Qt-939375996496a55a1bb424d6a328f47d2224ed51.tar.gz
Qt-939375996496a55a1bb424d6a328f47d2224ed51.tar.bz2
Improve input panel handling in declarative demos and examples
Task-number: QTBUG-11157 Reviewed-by: Warwick Allison
Diffstat (limited to 'demos/declarative/samegame/samegame.qml')
-rw-r--r--demos/declarative/samegame/samegame.qml20
1 files changed, 16 insertions, 4 deletions
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 54c18d6..9a721da 100644
--- a/demos/declarative/samegame/samegame.qml
+++ b/demos/declarative/samegame/samegame.qml
@@ -90,17 +90,31 @@ Rectangle {
enabled: initialWidth != 0
}
+ onOpened: nameInputText.focus = true;
+ onClosed: {
+ nameInputText.focus = false;
+ if (nameInputText.text != "")
+ Logic.saveHighScore(nameInputText.text);
+ }
Text {
id: dialogText
anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter }
text: "You won! Please enter your name: "
}
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (nameInputText.text == "")
+ nameInputText.openSoftwareInputPanel();
+ else
+ nameInputDialog.forceClose();
+ }
+ }
TextInput {
id: nameInputText
anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
- focus: true
-
+ focus: false
onTextChanged: {
var newWidth = nameInputText.width + dialogText.width + 40;
if ( (newWidth > nameInputDialog.width && newWidth < screen.width)
@@ -108,8 +122,6 @@ Rectangle {
nameInputDialog.width = newWidth;
}
onAccepted: {
- if (nameInputDialog.opacity == 1 && nameInputText.text != "")
- Logic.saveHighScore(nameInputText.text);
nameInputDialog.forceClose();
}
}