From 9f4ff8ce499dd0d50d0b04cb88ffa981dddd006e Mon Sep 17 00:00:00 2001 From: J-P Nurmi <jpnurmi@theqtcompany.com> Date: Thu, 6 Nov 2014 15:35:49 +0100 Subject: [PATCH] Let the cursor handle be visible regardless of selection The cursor handle is visible on Android even when there's no selection. Let the style decide when to show/hide the handles, but make sure to disable the corresponding MouseArea when a handle is hidden. Change-Id: I211c122998223ad25279bee2841c5b5e14d4c48e Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com> --- src/controls/Private/TextHandle.qml | 2 +- src/controls/Private/TextInputWithHandles.qml | 2 +- src/controls/Styles/iOS/CursorHandleStyle.qml | 1 + src/controls/TextArea.qml | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controls/Private/TextHandle.qml b/src/controls/Private/TextHandle.qml index 19fc19a6d..8656dcfd8 100644 --- a/src/controls/Private/TextHandle.qml +++ b/src/controls/Private/TextHandle.qml @@ -75,7 +75,7 @@ Loader { MouseArea { id: mouse anchors.fill: item - enabled: handle.active + enabled: item && item.visible preventStealing: true property real pressX property point offset diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml index ceb63084f..726b6863e 100644 --- a/src/controls/Private/TextInputWithHandles.qml +++ b/src/controls/Private/TextInputWithHandles.qml @@ -170,7 +170,7 @@ TextInput { x: mappedPos.x y: mappedPos.y - visible: pressed || (input.hasSelection && handleX + handleWidth >= -1 && handleX <= control.width + 1) + visible: pressed || ((input.cursorVisible || input.hasSelection) && handleX + handleWidth >= -1 && handleX <= control.width + 1) onPositionChanged: { if (!input.blockRecursion) { diff --git a/src/controls/Styles/iOS/CursorHandleStyle.qml b/src/controls/Styles/iOS/CursorHandleStyle.qml index 26ab97282..408a7bf46 100644 --- a/src/controls/Styles/iOS/CursorHandleStyle.qml +++ b/src/controls/Styles/iOS/CursorHandleStyle.qml @@ -45,6 +45,7 @@ Item { y: -20 width: 80 height: knob.height + knobLine.height + 60 + visible: styleData.hasSelection Rectangle { id: knob diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 8cfb6dfdf..691bf13e1 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -933,7 +933,7 @@ ScrollView { property var posInViewport: flickableItem.contentX !== flickableItem.contentY !== Number.MAX_VALUE ? parent.mapToItem(viewport, handleX, handleY) : -1 - visible: pressed || (edit.hasSelection + visible: pressed || ((edit.cursorVisible || edit.hasSelection) && posInViewport.y + handleHeight >= -1 && posInViewport.y <= viewport.height + 1 && posInViewport.x + handleWidth >= -1 -- GitLab