summaryrefslogtreecommitdiff
path: root/src/controls/TextArea.qml
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-09-04 10:03:06 +0200
committerJ-P Nurmi <jpnurmi@digia.com>2014-09-08 15:25:00 +0200
commit09c52335e0ad0e5b77adede6416efbdfe7121208 (patch)
treea89b0b545880af97767cc651aa7fb9defaf28940 /src/controls/TextArea.qml
parentff7a45a99a9e120b0ee426fcf17ac189f057823f (diff)
downloadqtquickcontrols-09c52335e0ad0e5b77adede6416efbdfe7121208.tar.gz
TextHandle: take parent into account when positioning the handles
The set the position of the handle parent agnostic (and take into account margins etc), we need to use mapFromItem to get the correct position. Change-Id: Iba56ecc0634b24b92f56923b9404ea9c9ab9a2d1 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls/TextArea.qml')
-rw-r--r--src/controls/TextArea.qml18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml
index 44c79122..03152763 100644
--- a/src/controls/TextArea.qml
+++ b/src/controls/TextArea.qml
@@ -860,8 +860,13 @@ ScrollView {
active: area.selectByMouse
delegate: __style.selectionHandle
maximum: cursorHandle.position - 1
- x: edit.selectionRectangle.x - flickableItem.contentX
- y: edit.selectionRectangle.y - flickableItem.contentY
+
+ // Mention contentX and contentY in the mappedPos binding to force re-evaluation if they change
+ property var mappedPos: flickableItem.contentX !== flickableItem.contentY !== Number.MAX_VALUE ?
+ parent.mapFromItem(editor, editor.selectionRectangle.x, editor.selectionRectangle.y) : -1
+ x: mappedPos.x
+ y: mappedPos.y
+
visible: pressed || (edit.hasSelection && handleY + handleHeight >= -1 && handleY <= viewport.height + 1
&& handleX + handleWidth >= -1 && handleX <= viewport.width + 1)
@@ -886,8 +891,13 @@ ScrollView {
active: area.selectByMouse
delegate: __style.cursorHandle
minimum: edit.hasSelection ? selectionHandle.position + 1 : -1
- x: edit.cursorRectangle.x - flickableItem.contentX
- y: edit.cursorRectangle.y - flickableItem.contentY
+
+ // Mention contentX and contentY in the mappedPos binding to force re-evaluation if they change
+ property var mappedPos: flickableItem.contentX !== flickableItem.contentY !== Number.MAX_VALUE ?
+ parent.mapFromItem(editor, editor.cursorRectangle.x, editor.cursorRectangle.y) : -1
+ x: mappedPos.x
+ y: mappedPos.y
+
visible: pressed || ((edit.cursorVisible || edit.hasSelection)
&& handleY + handleHeight >= -1 && handleY <= viewport.height + 1
&& handleX + handleWidth >= -1 && handleX <= viewport.width + 1)