diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-03-10 15:42:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-18 09:38:44 +0100 |
commit | 354ff5e7733703ba6304ccf3241ab35b3e235cf1 (patch) | |
tree | 0fe683ffa1af4d946cfd83bd83dd65c4f9f2389b /src/controls/Slider.qml | |
parent | 6aba49f84a17bad51f83968a03e5e9a58de726c6 (diff) | |
download | qtquickcontrols-354ff5e7733703ba6304ccf3241ab35b3e235cf1.tar.gz |
Slider: don't prevent stealing until drag threshold is exceeded
If a Slider is placed in a Flickable (or ListView, etc.),
preventStealing means that you cannot flick the flickable by dragging
over the Slider. It's better to postpone setting that until we
detect whether the user is really attempting to drag the slider,
because we don't want to rule out use cases such as vertical sliders
in a horizontal ListView or vice-versa, so that you drag in
one direction to move the slider and in another direction to flick.
Platform drag threshold is exposed in Settings (from QStyleHints).
(reverts/refines c9665f3e2d1eb12f1cc5a569c20f5d569fafde7f)
Change-Id: I82feda6028f6effa5b26ad575a1933e48e971453
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'src/controls/Slider.qml')
-rw-r--r-- | src/controls/Slider.qml | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index e2be07d8..c2869563 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -218,8 +218,9 @@ Control { anchors.fill: parent hoverEnabled: true - preventStealing: true property int clickOffset: 0 + property real pressX: 0 + property real pressY: 0 function clamp ( val ) { return Math.max(range.positionAtMinimum, Math.min(range.positionAtMaximum, val)) @@ -229,6 +230,8 @@ Control { if (pressed && __horizontal) { var pos = clamp (mouse.x + clickOffset - fakeHandle.width/2) fakeHandle.x = pos + if (Math.abs(mouse.x - pressX) >= Settings.dragThreshold) + preventStealing = true } } @@ -236,6 +239,8 @@ Control { if (pressed && !__horizontal) { var pos = clamp (mouse.y + clickOffset- fakeHandle.height/2) fakeHandle.y = pos + if (Math.abs(mouse.y - pressY) >= Settings.dragThreshold) + preventStealing = true } } @@ -247,6 +252,8 @@ Control { if (fakeHandle.contains(Qt.point(point.x, point.y))) { clickOffset = __horizontal ? fakeHandle.width/2 - point.x : fakeHandle.height/2 - point.y } + pressX = mouse.x + pressY = mouse.y } onReleased: { @@ -255,6 +262,7 @@ Control { if (!slider.updateValueWhileDragging) range.position = __horizontal ? fakeHandle.x : fakeHandle.y; clickOffset = 0 + preventStealing = false } } |