Added scrolling and cursor following to message update editor.
authorSami Rämö <sami.ramo@ixonos.com>
Wed, 24 Nov 2010 15:29:00 +0000 (17:29 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Wed, 24 Nov 2010 15:29:00 +0000 (17:29 +0200)
src/qmlui/DetailEditorRow.qml
src/qmlui/ExtendedTextEdit.qml

index c85eb76..1d785e4 100644 (file)
@@ -67,8 +67,8 @@ Item {
             top: textEditRowBox.top
         }
         height: paintedHeight
-        onActiveFocusChanged: {
-            if (activeFocus)
+        onEditorFocusChanged: {
+            if (editorFocus)
                 parent.state = "edit"
         }
         onCharacterCountChanged: {
index 040e262..9c722e9 100644 (file)
@@ -1,16 +1,45 @@
 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)
+    }
 }