aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/tutorials/gettingStartedQml/core/TextArea.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/tutorials/gettingStartedQml/core/TextArea.qml')
-rw-r--r--examples/quick/tutorials/gettingStartedQml/core/TextArea.qml36
1 files changed, 20 insertions, 16 deletions
diff --git a/examples/quick/tutorials/gettingStartedQml/core/TextArea.qml b/examples/quick/tutorials/gettingStartedQml/core/TextArea.qml
index c9294ca5d5..dd6b89547f 100644
--- a/examples/quick/tutorials/gettingStartedQml/core/TextArea.qml
+++ b/examples/quick/tutorials/gettingStartedQml/core/TextArea.qml
@@ -41,45 +41,49 @@
import QtQuick 2.0
Rectangle {
- id:textArea
+ id: textArea
function paste() { textEdit.paste() }
function copy() { textEdit.copy() }
function selectAll() { textEdit.selectAll() }
- width :400; height:400
+ width: 400; height: 400
property color fontColor: "white"
property alias textContent: textEdit.text
+
Flickable {
id: flickArea
- width: parent.width; height: parent.height
- anchors.fill:parent
+ width: parent.width
+ height: parent.height
+ anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.HorizontalFlick
interactive: true
- //Will move the text Edit area to make the area visible when
- //scrolled with keyboard strokes
+
+ // Move the content coordinates to make the text area
+ // visible when scrolled with keyboard strokes
function ensureVisible(r) {
if (contentX >= r.x)
- contentX = r.x;
- else if (contentX+width <= r.x+r.width)
- contentX = r.x+r.width-width;
+ 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;
+ contentY = r.y;
+ else if (contentY + height <= r.y + r.height)
+ contentY = r.y + r.height - height;
}
TextEdit {
id: textEdit
- anchors.fill:parent
- width:parent.width; height:parent.height
- color:fontColor
+ anchors.fill: parent
+ width: parent.width
+ height: parent.height
+ color: fontColor
focus: true
wrapMode: TextEdit.Wrap
- font.pointSize:10
+ font.pointSize: 10
onCursorRectangleChanged: flickArea.ensureVisible(cursorRectangle)
selectByMouse: true
}