-
Notifications
You must be signed in to change notification settings - Fork 0
/
MPInputBox.qml
62 lines (52 loc) · 1.32 KB
/
MPInputBox.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @file MPInputBox.qml
* @brief MPInputBox stands for "multi-purpose InputBox"
* @author Giang Nguyen
* Contact: [email protected]
*/
import QtQuick 2.9
FocusScope {
id: inputbox
property string content: textinput.text
property string hint
signal clear
onClear: {
textinput.text = ""
}
Text {
id: placeholder
anchors.fill: parent
anchors.leftMargin: 8
verticalAlignment: Text.AlignVCenter
text: hint
color: "lightgrey"
font.pointSize: 14
}
MouseArea {
anchors.fill: parent
onClicked: inputbox.focus = true
}
TextInput {
id: textinput
anchors.fill: parent
anchors.leftMargin: 8
verticalAlignment: Text.AlignVCenter
focus: true
selectByMouse: true
font.pointSize: 14
}
states: [
State {
name: "showPlaceholder"
when:(textinput.text === "")
PropertyChanges { target: placeholder; opacity:1 }
PropertyChanges { target: textinput; opacity:0 }
},
State {
name: "showTextInput"
when:(textinput.text !== "")
PropertyChanges { target: placeholder; opacity:0 }
PropertyChanges { target: textinput; opacity:1 }
}
]
}