summaryrefslogtreecommitdiff
path: root/src/controls/Private/TextInputWithHandles.qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-03-09 16:38:39 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-16 06:56:52 +0000
commit19159469400ed6daa8bba1020eaaf149a16f1f18 (patch)
treef31f193a27499994ce3545b612f84ef37d6ae91a /src/controls/Private/TextInputWithHandles.qml
parentc439f4635a17101ceb410b3c2416bf15c6d00d80 (diff)
downloadqtquickcontrols-19159469400ed6daa8bba1020eaaf149a16f1f18.tar.gz
Fix text selection handles to float on top
Task-number: QTBUG-42538 Change-Id: Ia6d38819c994dcd9713958faf0c17de2023c9f25 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'src/controls/Private/TextInputWithHandles.qml')
-rw-r--r--src/controls/Private/TextInputWithHandles.qml21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml
index f931986f..1c40f588 100644
--- a/src/controls/Private/TextInputWithHandles.qml
+++ b/src/controls/Private/TextInputWithHandles.qml
@@ -35,6 +35,7 @@
****************************************************************************/
import QtQuick 2.2
+import QtQuick.Window 2.2
import QtQuick.Controls.Private 1.0
TextInput {
@@ -128,16 +129,25 @@ TextInput {
anchors.fill: parent
}
+ ScenePosListener {
+ id: listener
+ item: input
+ enabled: input.activeFocus && Qt.platform.os !== "ios" && Settings.isMobile
+ }
+
TextHandle {
id: selectionHandle
editor: input
- parent: control
+ z: 1000001 // DefaultWindowDecoration+1
+ parent: !input.activeFocus || Qt.platform.os === "ios" ? control : Window.contentItem // float (QTBUG-42538)
control: input.control
active: control.selectByMouse && Settings.isMobile
maximum: cursorHandle.position - 1
- property var mappedPos: parent.mapFromItem(editor, editor.selectionRectangle.x, editor.selectionRectangle.y)
+ // Mention scenePos in the mappedPos binding to force re-evaluation if it changes
+ property var mappedPos: listener.scenePos.x !== listener.scenePos.y !== Number.MAX_VALUE ?
+ editor.mapToItem(parent, editor.selectionRectangle.x, editor.selectionRectangle.y) : -1
x: mappedPos.x
y: mappedPos.y
@@ -158,12 +168,15 @@ TextInput {
id: cursorHandle
editor: input
- parent: control
+ z: 1000001 // DefaultWindowDecoration+1
+ parent: !input.activeFocus || Qt.platform.os === "ios" ? control : Window.contentItem // float (QTBUG-42538)
control: input.control
active: control.selectByMouse && Settings.isMobile
minimum: input.hasSelection ? selectionHandle.position + 1 : -1
- property var mappedPos: parent.mapFromItem(editor, editor.cursorRectangle.x, editor.cursorRectangle.y)
+ // Mention scenePos in the mappedPos binding to force re-evaluation if it changes
+ property var mappedPos: listener.scenePos.x !== listener.scenePos.y !== Number.MAX_VALUE ?
+ editor.mapToItem(parent, editor.cursorRectangle.x, editor.cursorRectangle.y) : -1
x: mappedPos.x
y: mappedPos.y