summaryrefslogtreecommitdiff
path: root/src/controls/Private/TextInputWithHandles.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/Private/TextInputWithHandles.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/Private/TextInputWithHandles.qml')
-rw-r--r--src/controls/Private/TextInputWithHandles.qml15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml
index f955ed28..291d3a5f 100644
--- a/src/controls/Private/TextInputWithHandles.qml
+++ b/src/controls/Private/TextInputWithHandles.qml
@@ -123,9 +123,11 @@ TextInput {
control: input.control
active: control.selectByMouse
maximum: cursorHandle.position - 1
- readonly property real selectionX: input.selectionRectangle.x
- x: input.x + (pressed ? Math.max(0, selectionX) : selectionX)
- y: input.selectionRectangle.y + input.y
+
+ property var mappedPos: parent.mapFromItem(editor, editor.selectionRectangle.x, editor.selectionRectangle.y)
+ x: mappedPos.x
+ y: mappedPos.y
+
visible: pressed || (input.hasSelection && handleX + handleWidth >= -1 && handleX <= control.width + 1)
onPositionChanged: {
@@ -148,8 +150,11 @@ TextInput {
active: control.selectByMouse
delegate: style.cursorHandle
minimum: input.hasSelection ? selectionHandle.position + 1 : -1
- x: input.cursorRectangle.x + input.x
- y: input.cursorRectangle.y + input.y
+
+ property var mappedPos: parent.mapFromItem(editor, editor.cursorRectangle.x, editor.cursorRectangle.y)
+ x: mappedPos.x
+ y: mappedPos.y
+
visible: pressed || ((input.cursorVisible || input.hasSelection)
&& handleX + handleWidth >= -1 && handleX <= control.width + 1)