From 09c52335e0ad0e5b77adede6416efbdfe7121208 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 4 Sep 2014 10:03:06 +0200 Subject: 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 --- src/controls/TextArea.qml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/controls/TextArea.qml') 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) -- cgit v1.2.1