From aa510d9ac0bd1ecab6baa260d3ff5f2a64eb3acf Mon Sep 17 00:00:00 2001 From: J-P Nurmi <jpnurmi@theqtcompany.com> Date: Tue, 4 Nov 2014 17:27:28 +0100 Subject: [PATCH] Slider: fix tap-to-set-value on touch screens Change-Id: I7784b3a8266f889bc2079da4c64096eb9d50d6f5 Task-number: QTBUG-42252 Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com> --- src/controls/Slider.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index b06fcf3ae..d43923c1b 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -237,21 +237,21 @@ Control { return Math.max(range.positionAtMinimum, Math.min(range.positionAtMaximum, val)) } - function updateHandlePosition(mouse) { + function updateHandlePosition(mouse, force) { var pos, overThreshold if (__horizontal) { pos = clamp (mouse.x + clickOffset - fakeHandle.width/2) overThreshold = Math.abs(mouse.x - pressX) >= Settings.dragThreshold if (overThreshold) preventStealing = true - if (overThreshold || !Settings.hasTouchScreen) + if (overThreshold || force) fakeHandle.x = pos } else if (!__horizontal) { pos = clamp (mouse.y + clickOffset- fakeHandle.height/2) overThreshold = Math.abs(mouse.y - pressY) >= Settings.dragThreshold if (overThreshold) preventStealing = true - if (overThreshold || !Settings.hasTouchScreen) + if (overThreshold || force) fakeHandle.y = pos } } @@ -274,10 +274,11 @@ Control { } pressX = mouse.x pressY = mouse.y - updateHandlePosition(mouse) + updateHandlePosition(mouse, !Settings.hasTouchScreen) } onReleased: { + updateHandlePosition(mouse, Settings.hasTouchScreen) // If we don't update while dragging, this is the only // moment that the range is updated. if (!slider.updateValueWhileDragging) -- GitLab