| 1 |
import QtQuick 2.2 |
| 2 |
|
| 3 |
Item { |
| 4 |
id: root |
| 5 |
|
| 6 |
property alias text: input.text |
| 7 |
property alias label: labelText.text |
| 8 |
|
| 9 |
signal editingFinished |
| 10 |
|
| 11 |
implicitHeight: 30 |
| 12 |
implicitWidth: 200 |
| 13 |
|
| 14 |
Text { |
| 15 |
id: labelText |
| 16 |
|
| 17 |
anchors.left: parent.left |
| 18 |
anchors.right: inputFrame.left |
| 19 |
anchors.verticalCenter: parent.verticalCenter |
| 20 |
} |
| 21 |
|
| 22 |
Rectangle { |
| 23 |
id: inputFrame |
| 24 |
border.width: 2 |
| 25 |
border.color: input.focus ? "orange" : "#9f9f9f" |
| 26 |
color: "#3f3f3f" |
| 27 |
width: parent.width * 0.5 |
| 28 |
anchors.right: parent.right |
| 29 |
height: root.height |
| 30 |
|
| 31 |
TextInput { |
| 32 |
id: input |
| 33 |
|
| 34 |
anchors { |
| 35 |
left: parent.left |
| 36 |
leftMargin: 8 |
| 37 |
right: parent.right |
| 38 |
rightMargin: 8 |
| 39 |
verticalCenter: parent.verticalCenter |
| 40 |
} |
| 41 |
|
| 42 |
onActiveFocusChanged: { |
| 43 |
if (activeFocus) { |
| 44 |
selectAll(); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
verticalAlignment: Text.AlignVCenter |
| 49 |
|
| 50 |
onEditingFinished: { |
| 51 |
root.editingFinished(); |
| 52 |
} |
| 53 |
|
| 54 |
color: "#9f9f9f" |
| 55 |
} |
| 56 |
} |
| 57 |
} |