import Qt 4.7
-TextEdit {
- id: textEdit
+Flickable {
+ id: flick
property int characterCount: 0
+ property alias text : textEdit.text
+ property alias paintedHeight: textEdit.paintedHeight
+ property bool editorFocus: false
+ property alias font: textEdit.font
- focus: true
- selectByMouse: true
- font.pixelSize: 18
- clip: true;
- wrapMode: TextEdit.Wrap
- textFormat: TextEdit.PlainText
- onTextChanged: { characterCount = text.length }
+ contentWidth: textEdit.paintedWidth
+ contentHeight: textEdit.paintedHeight
+ clip: true
+
+ function ensureVisible(r)
+ {
+ if (contentX >= r.x)
+ contentX = r.x;
+ else if (contentX+width <= r.x+r.width)
+ contentX = r.x+r.width-width;
+ if (contentY >= r.y)
+ contentY = r.y;
+ else if (contentY+height <= r.y+r.height)
+ contentY = r.y+r.height-height;
+ }
+
+ TextEdit {
+ id: textEdit
+
+ width: flick.width
+ height: flick.height
+
+ focus: true
+ selectByMouse: true
+ font.pixelSize: 18
+ wrapMode: TextEdit.Wrap
+ textFormat: TextEdit.PlainText
+
+ onTextChanged: { characterCount = text.length }
+ onActiveFocusChanged: editorFocus = activeFocus
+ onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
+ }
}