blob: 210267768567683e6697c6a8fd981e6feb2ea4b5 (
plain)
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
123
|
import QtQuick 2.0
import "coordinate.js" as CONFIG
import "../com/neusoft/auto/widgets"
FocusScope {
id: focusScope
property string textOfInput: textInput.text
property string defaultShowingText: textInput.text
property var maxLengthOfInput;
property int textInputWidth;
property int textInputHeight;
property alias maxnumlength: textInput.maximumLength;
focus:false
// BorderImage {
// source: "../images/lineedit-bg.png"
// width: parent.width; height: parent.height
// border { left: 4; top: 4; right: 4; bottom: 4 }
// }
onVisibleChanged:
{
focusScope.focus = false
}
Text {
id: defaultText
anchors.fill: parent;
verticalAlignment: Text.AlignTop
text: defaultShowingText
color: "grey"
font.pixelSize:CONFIG.REMINDER_BTN_FONT_SIZE
}
MouseArea {
anchors.fill: parent
onClicked:
{
if(!focusScope.focus){
focusScope.focus = true;
}
textInput.cursorPosition = textInput.text.length;
}
}
TextInput {
id: textInput
width:textInputWidth
cursorVisible :focusScope.focus?true:false
wrapMode: TextEdit.Wrap
maximumLength:maxLengthOfInput
focus: true
font.pixelSize:CONFIG.REMINDER_BTN_FONT_SIZE
color: "#ffffff"
onCursorPositionChanged:
{
if(textInput.text.length == maximumLength)
{
console.debug("lengthlengthlengthlengthlengthlengthlengthlength")
keyBoard.maximumState=true
}
else if(textInput.text.length < maximumLength)
{
keyBoard.maximumState=false
}
}
}
onFocusChanged:{
if(focusScope.focus){
textInput.focus=true
systemCtrl.setTextInputHandle(textInput);
}
if(!keyBoard.visible)
{
keyBoard.visible=true;
}
}
// Image {
// id: clear
// anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
// source: "../images/clear.png"
// opacity: 0
// MouseArea {
// anchors.fill: parent
// onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); }
// }
// }
states: State {
name: "hasText"; when: textInput.text != ''
PropertyChanges { target: defaultText; opacity: 0 }
//PropertyChanges { target: clear; opacity: 1 }
}
transitions: [
Transition {
from: ""; to: "hasText"
NumberAnimation { exclude: defaultText; properties: "opacity" }
},
Transition {
from: "hasText"; to: ""
NumberAnimation { properties: "opacity" }
}
]
/*========================================Function Start==============================================*/
function clearText()
{
textInput.text = "";
}
function setText(text)
{
textInput.text = text;
}
/*========================================Function End================================================*/
}
|