summaryrefslogtreecommitdiffstats
path: root/demos/declarative/samegame
diff options
context:
space:
mode:
Diffstat (limited to 'demos/declarative/samegame')
-rw-r--r--demos/declarative/samegame/SamegameCore/Dialog.qml5
-rw-r--r--demos/declarative/samegame/samegame.qml20
2 files changed, 19 insertions, 6 deletions
diff --git a/demos/declarative/samegame/SamegameCore/Dialog.qml b/demos/declarative/samegame/SamegameCore/Dialog.qml
index 8dd12f6800..c71a4b3a37 100644
--- a/demos/declarative/samegame/SamegameCore/Dialog.qml
+++ b/demos/declarative/samegame/SamegameCore/Dialog.qml
@@ -47,13 +47,14 @@ Rectangle {
property Item text: dialogText
signal closed
-
+ signal opened
function forceClose() {
page.closed();
page.opacity = 0;
}
function show(txt) {
+ page.opened();
dialogText.text = txt;
page.opacity = 1;
}
@@ -62,7 +63,7 @@ Rectangle {
color: "white"
border.width: 1
opacity: 0
-
+ visible: opacity > 0
Behavior on opacity {
NumberAnimation { duration: 1000 }
}
diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml
index 54c18d6e42..9a721da658 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();
}
}