WWW update
[ubi] / qml / ubi / components / TextField.qml
1 import QtQuick 1.0
2
3 Rectangle {
4     id: root
5
6     property alias text : input.text
7     property alias echoMode : input.echoMode
8     property alias inputFocus: input.focus
9     property alias placeholderText: placeholder.text
10
11     signal textChanged
12
13     height: 50
14
15     color:  "white"
16     border.width: 3
17     border.color: input.activeFocus ? "black" : "grey"
18
19     function closeSoftwareInputPanel() {
20         input.focus = false;
21         input.closeSoftwareInputPanel();
22     }
23
24     TextInput {
25         id: input
26
27         anchors { fill: parent; leftMargin: 6; rightMargin: 6; topMargin: 6; bottomMargin: 6 }
28         font.pixelSize: 30
29         selectByMouse: true
30         selectionColor: "gray"
31         onTextChanged: root.textChanged()
32         //focus: true
33
34         Keys.onPressed: {
35             if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) {
36                 closeSoftwareInputPanel();
37                 focus = false;
38                 dummy.focus = true;
39             }
40         }
41
42         onFocusChanged: {
43             if(focus == false) {
44                 closeSoftwareInputPanel();
45             }
46         }
47
48     }
49     Item { id: dummy }
50
51     Text {
52         id: placeholder
53
54         anchors { fill: parent; leftMargin: 6; rightMargin: 6; topMargin: 6; bottomMargin: 6 }
55         font.pixelSize: input.font.pixelSize
56         clip: true
57         visible: (!input.activeFocus) && (input.text == "")
58         color: "gray"
59         font.italic: true
60     }
61
62 }