-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFocusBoxTextEdit.qml
122 lines (97 loc) · 2.67 KB
/
FocusBoxTextEdit.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import QtQuick 2.5
FocusScope {
id: focusScope
property string fontFamily: "open sans light"
property alias value: textInput.text;
property int fontSize: 27
property alias textColor: textInput.color;
property alias backgroundText: typeSomething.text;
property alias icon: iconSource.source
property alias inputMethodHints: textInput.inputMethodHints
height: 48
Rectangle {
id: background;
anchors.fill: parent
radius: 13
antialiasing: true
border {
width: 1
color: focusScope.activeFocus ? "#FF14ABBE" : "#FF808080"
}
Image {
id: backgroundAsset
height: parent.height
width: 52
anchors {
left: parent.left
top: parent.top
}
source: focusScope.activeFocus ? "Images/asset_iconholderON.png" : "Images/asset_iconholder.png"
}
Image {
id: iconSource
height: parent.height
width: 52
anchors {
left: parent.left
top: parent.top
}
}
}
TextInput {
id: textInput;
focus: true
selectByMouse: true
font {
pixelSize: fontSize
family: fontFamily
}
wrapMode: TextEdit.NoWrap
color: focusScope.activeFocus ? "#FF14ABBE" : "#FF808080"
anchors {
fill: parent
leftMargin: 68
rightMargin: 68
}
verticalAlignment: TextInput.AlignVCenter
clip: true
}
Text {
id: typeSomething;
text: "Type something..."
color: "#FF808080"
opacity: ((value === "" && !textInput.inputMethodComposing) ? 1.0 : 0.0);
font {
family: fontFamily
pixelSize: fontSize
}
anchors {
left: parent.left
right: parent.right
leftMargin: 68
verticalCenter: parent.verticalCenter;
}
Behavior on opacity { NumberAnimation { duration: 250; } }
}
MouseArea {
enabled: !focusScope.activeFocus
anchors.fill: parent
onClicked: textInput.forceActiveFocus()
}
Image {
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
source: "Images/icon_clear.png"
Behavior on opacity { NumberAnimation { duration: 250; } }
MouseArea {
anchors.fill: parent
onClicked: {
value = "";
textInput.focus = false
textInput.forceActiveFocus()
}
}
}
}