blob: fd29eb6972efc9d7cca606cb278deed685f182bc (
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
|
import QtQuick 1.0
Item {
id:lineedit
property alias text: textEdit.text
width: 240 + 11 //Should be set manually in most cases
height: textEdit.height + 11
Rectangle{
color: 'lightsteelblue'
anchors.fill: parent
}
clip: true
Component.onCompleted: textEdit.cursorPosition = 0;
TextEdit{
id:textEdit
cursorDelegate: Item{
Rectangle{
visible: parent.parent.focus
color: "#009BCE"
height: 13
width: 2
y: 1
}
}
property int leftMargin: 6
property int topMargin: 6
property int rightMargin: 6
property int bottomMargin: 6
x: leftMargin
width: parent.width - leftMargin - rightMargin;
y: 5
//Below function implements all scrolling logic
onCursorPositionChanged: {
if(cursorRectangle.y < topMargin - textEdit.y){//Cursor went off the front
textEdit.y = topMargin - Math.max(0, cursorRectangle.y);
}else if(cursorRectangle.y > parent.height - topMargin - bottomMargin - textEdit.y){//Cursor went off the end
textEdit.y = topMargin - Math.max(0, cursorRectangle.y - (parent.height - topMargin - bottomMargin) + cursorRectangle.height);
}
}
onHeightChanged: y=topMargin//reset scroll
text:""
horizontalAlignment: TextInput.AlignLeft
wrapMode: TextEdit.WordWrap
font.pixelSize:15
}
MouseArea{
//Implements all line edit mouse handling
id: mainMouseArea
anchors.fill: parent;
function translateY(y){
return y - textEdit.y
}
function translateX(x){
return x - textEdit.x
}
onPressed: {
textEdit.focus = true;
textEdit.cursorPosition = textEdit.positionAt(translateX(mouse.x), translateY(mouse.y));
}
onPositionChanged: {
textEdit.moveCursorSelection(textEdit.positionAt(translateX(mouse.x), translateY(mouse.y)));
}
onReleased: {
}
onDoubleClicked: {
textEdit.selectAll()
}
z: textEdit.z + 1
}
}
|