diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2014-08-18 13:46:50 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@digia.com> | 2014-09-08 15:25:05 +0200 |
commit | 7e2d0b84ac2d3b3fc45e5276917a3dccb8750b3d (patch) | |
tree | e91219d9d64b968fb1712bd0db5df2c3e37cf9fd /src/controls/Private | |
parent | 09c52335e0ad0e5b77adede6416efbdfe7121208 (diff) | |
download | qtquickcontrols-7e2d0b84ac2d3b3fc45e5276917a3dccb8750b3d.tar.gz |
TextHandle: clear selection when handle clicked
If the handle is clicked without being dragged we
should clear the selection.
Since the handle will move along with the drag, we
cannot rely on the MouseAreas own clicked signal
since that one will get confused and fire also after
a drag.
Change-Id: I4e611e73a6f76822e1008ccf75f0f5562fc673dc
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls/Private')
-rw-r--r-- | src/controls/Private/TextHandle.qml | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/controls/Private/TextHandle.qml b/src/controls/Private/TextHandle.qml index 993f621d..55526203 100644 --- a/src/controls/Private/TextHandle.qml +++ b/src/controls/Private/TextHandle.qml @@ -78,8 +78,11 @@ Loader { enabled: handle.active property real pressX property point offset + property bool handleDragged: false + onPressed: { Qt.inputMethod.commit() + handleDragged = false pressX = mouse.x var handleRect = editor.positionToRectangle(handle.position) var centerX = handleRect.x + (handleRect.width / 2) @@ -87,12 +90,22 @@ Loader { var center = mapFromItem(editor, centerX, centerY) offset = Qt.point(mouseX - center.x, mouseY - center.y) } - onReleased: preventStealing = false + onReleased: { + preventStealing = false + if (!handleDragged) { + // The user just clicked on the handle. In that + // case clear the selection. + var mousePos = editor.mapFromItem(item, mouse.x, mouse.y) + var editorPos = editor.positionAt(mousePos.x, mousePos.y) + editor.select(editorPos, editorPos) + } + } onMouseXChanged: { if (Math.abs(mouse.x - pressX) >= Settings.dragThreshold) preventStealing = true } onPositionChanged: { + handleDragged = true var pt = mapToItem(editor, mouse.x - offset.x, mouse.y - offset.y) // limit vertically within mix/max coordinates or content bounds |