summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-07-18 20:57:23 +0200
committerLiang Qi <liang.qi@digia.com>2014-07-21 14:35:18 +0200
commitffdfaf029208a33ad83c9d0545b9b67bd10df441 (patch)
tree33bf6f2cd5d1e40b37b60b3c14df696c4c77c9e6
parentca73389c6a2afd7e88a9bd16333c27fc82fb5c61 (diff)
Make text selection handles behave in a Flickable
Prevent stealing but not before the drag threshold has been passed. This makes it possible to flick over the handles, but the press won't get easily stolen by a Flickable after moving the handles. The same technique is used in Slider. Change-Id: I8eac1bf84ada8bb2334f5ed3985f14a520ecc3c5 Reviewed-by: Liang Qi <liang.qi@digia.com>
-rw-r--r--src/controls/Private/TextHandle.qml13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/controls/Private/TextHandle.qml b/src/controls/Private/TextHandle.qml
index cac805295..5bef41946 100644
--- a/src/controls/Private/TextHandle.qml
+++ b/src/controls/Private/TextHandle.qml
@@ -38,6 +38,8 @@
**
****************************************************************************/
import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Controls.Private 1.0
Loader {
id: handle
@@ -74,8 +76,17 @@ Loader {
id: mouse
anchors.fill: item
enabled: handle.active
+ property real pressX
property point offset
- onPressed: offset = Qt.point(x + mouse.x, y + mouse.y)
+ onPressed: {
+ pressX = mouse.x
+ offset = Qt.point(x + mouse.x, y + mouse.y)
+ }
+ onReleased: preventStealing = false
+ onMouseXChanged: {
+ if (Math.abs(mouse.x - pressX) >= Settings.dragThreshold)
+ preventStealing = true
+ }
onPositionChanged: {
var pt = mapToItem(editor, mouse.x - offset.x, mouse.y - offset.y)