Commit aa510d9a authored by J-P Nurmi's avatar J-P Nurmi
Browse files

Slider: fix tap-to-set-value on touch screens


Change-Id: I7784b3a8266f889bc2079da4c64096eb9d50d6f5
Task-number: QTBUG-42252
Reviewed-by: default avatarCaroline Chao <caroline.chao@theqtcompany.com>
Showing with 5 additions and 4 deletions
...@@ -237,21 +237,21 @@ Control { ...@@ -237,21 +237,21 @@ Control {
return Math.max(range.positionAtMinimum, Math.min(range.positionAtMaximum, val)) return Math.max(range.positionAtMinimum, Math.min(range.positionAtMaximum, val))
} }
function updateHandlePosition(mouse) { function updateHandlePosition(mouse, force) {
var pos, overThreshold var pos, overThreshold
if (__horizontal) { if (__horizontal) {
pos = clamp (mouse.x + clickOffset - fakeHandle.width/2) pos = clamp (mouse.x + clickOffset - fakeHandle.width/2)
overThreshold = Math.abs(mouse.x - pressX) >= Settings.dragThreshold overThreshold = Math.abs(mouse.x - pressX) >= Settings.dragThreshold
if (overThreshold) if (overThreshold)
preventStealing = true preventStealing = true
if (overThreshold || !Settings.hasTouchScreen) if (overThreshold || force)
fakeHandle.x = pos fakeHandle.x = pos
} else if (!__horizontal) { } else if (!__horizontal) {
pos = clamp (mouse.y + clickOffset- fakeHandle.height/2) pos = clamp (mouse.y + clickOffset- fakeHandle.height/2)
overThreshold = Math.abs(mouse.y - pressY) >= Settings.dragThreshold overThreshold = Math.abs(mouse.y - pressY) >= Settings.dragThreshold
if (overThreshold) if (overThreshold)
preventStealing = true preventStealing = true
if (overThreshold || !Settings.hasTouchScreen) if (overThreshold || force)
fakeHandle.y = pos fakeHandle.y = pos
} }
} }
...@@ -274,10 +274,11 @@ Control { ...@@ -274,10 +274,11 @@ Control {
} }
pressX = mouse.x pressX = mouse.x
pressY = mouse.y pressY = mouse.y
updateHandlePosition(mouse) updateHandlePosition(mouse, !Settings.hasTouchScreen)
} }
onReleased: { onReleased: {
updateHandlePosition(mouse, Settings.hasTouchScreen)
// If we don't update while dragging, this is the only // If we don't update while dragging, this is the only
// moment that the range is updated. // moment that the range is updated.
if (!slider.updateValueWhileDragging) if (!slider.updateValueWhileDragging)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment