diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-06-03 06:27:47 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-06-03 06:53:11 (GMT) |
commit | 939375996496a55a1bb424d6a328f47d2224ed51 (patch) | |
tree | e196085fb599e38fe6a19491500c33f8b9119a8c /examples/declarative | |
parent | 26d65a844b20a0056820c15188532b3895a3e091 (diff) | |
download | Qt-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 'examples/declarative')
6 files changed, 32 insertions, 6 deletions
diff --git a/examples/declarative/text/edit/edit.qml b/examples/declarative/text/edit/edit.qml index 0be42e9..4668ab2 100644 --- a/examples/declarative/text/edit/edit.qml +++ b/examples/declarative/text/edit/edit.qml @@ -121,6 +121,9 @@ Rectangle { onClicked: { if (editor.state == "") { edit.cursorPosition = edit.positionAt(mouse.x+x,mouse.y+y); + if (!edit.focus) + edit.focus = true; + edit.openSoftwareInputPanel(); } } function hitHandle(h,x,y) { return x>=h.x+flick.contentX && x<h.x+flick.contentX+h.width && y>=h.y+flick.contentY && y<h.y+flick.contentY+h.height } diff --git a/examples/declarative/toys/corkboards/Day.qml b/examples/declarative/toys/corkboards/Day.qml index f9c901f..cc297b1 100644 --- a/examples/declarative/toys/corkboards/Day.qml +++ b/examples/declarative/toys/corkboards/Day.qml @@ -49,6 +49,11 @@ Component { Image { source: "cork.jpg" } + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + Text { text: name; x: 15; y: 8; height: 40; width: 370 font.pixelSize: 18; font.bold: true; color: "white" @@ -106,7 +111,7 @@ Component { drag.maximumY: page.height - 80 drag.minimumX: 100 drag.maximumX: page.width - 140 - onClicked: { myText.focus = true } + onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } } } } diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qml b/examples/declarative/toys/dynamicscene/dynamicscene.qml index 659a257..1edb841 100644 --- a/examples/declarative/toys/dynamicscene/dynamicscene.qml +++ b/examples/declarative/toys/dynamicscene/dynamicscene.qml @@ -50,7 +50,12 @@ Item { //This is a desktop-sized example width: 800; height: 480 - + + MouseArea { + anchors.fill: parent + onClicked: window.focus = false; + } + //This is the message box that pops up when there's an error Rectangle { id: dialog diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml index d235d35..c216c08 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml @@ -58,10 +58,12 @@ Rectangle { function showWithInput(text) { show(text); textInput.opacity = 1; + textInput.focus = true; textInput.text = "" } function hide() { + textInput.focus = false; container.opacity = 0; container.closed(); } @@ -70,6 +72,7 @@ Rectangle { width: dialogText.width + textInput.width + 20 height: dialogText.height + 20 opacity: 0 + visible: opacity > 0 Text { id: dialogText @@ -82,7 +85,6 @@ Rectangle { id: textInput anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } width: 80 - focus: true text: "" onAccepted: container.hide() // close dialog when Enter is pressed @@ -91,7 +93,13 @@ Rectangle { MouseArea { anchors.fill: parent - onClicked: hide(); + + onClicked: { + if (textInput.text == "" && textInput.opacity > 0) + textInput.openSoftwareInputPanel(); + else + hide(); + } } //![3] diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml index c022626..eaa6b6b 100644 --- a/examples/declarative/ui-components/searchbox/SearchBox.qml +++ b/examples/declarative/ui-components/searchbox/SearchBox.qml @@ -66,7 +66,7 @@ FocusScope { font.italic: true } - MouseArea { anchors.fill: parent; onClicked: focusScope.focus = true } + MouseArea { anchors.fill: parent; onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } } TextInput { id: textInput @@ -82,7 +82,7 @@ FocusScope { MouseArea { anchors.fill: parent - onClicked: { textInput.text = ''; focusScope.focus = true } + onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } } } diff --git a/examples/declarative/ui-components/searchbox/main.qml b/examples/declarative/ui-components/searchbox/main.qml index 0508d5a..bf3bed8 100644 --- a/examples/declarative/ui-components/searchbox/main.qml +++ b/examples/declarative/ui-components/searchbox/main.qml @@ -41,9 +41,14 @@ import Qt 4.7 Rectangle { + id: page width: 500; height: 250 color: "#edecec" + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } Column { anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } spacing: 10 |