diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-04-24 08:51:47 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2017-04-27 16:10:53 +0000 |
commit | 47479c0e969a3b3d220c77b8bb7cb8f2d58c07ae (patch) | |
tree | 7868201449b1f03df288188f95ce7eda955c7192 /tests/manual/pointer/content/Slider.qml | |
parent | 822e39df38b20763d2933d7a6d2d6ddf7b9b2639 (diff) |
DragHandler: allow parent to be different from target
The most obvious way to implement a Slider is to allow dragging the
knob - as on a real-world physical sliding potentiometer. But to make
it easier on a touchscreen, it should be possible to touch anywhere
along the slider's travel, as on a QtQuick.Controls 2 Slider. For
that purpose, we need to respond to events within the bounds of one
Item while actually dragging a different Item (the knob). It's
similar to the way that PinchHandler can handle pinch gestures within
one Item while transforming another (which may be too small to get
both fingers inside).
Change-Id: Iac9a5f11a7a45e22d93fe52bf62d157c48d72d3d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/manual/pointer/content/Slider.qml')
-rw-r--r-- | tests/manual/pointer/content/Slider.qml | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index 44dea8e33b..ecf45c02f3 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -50,6 +50,15 @@ Item { property alias pressed: tap.isPressed signal tapped + DragHandler { + id: dragHandler + objectName: label.text + " DragHandler" + target: knob + xAxis.enabled: false + yAxis.minimum: slot.y + yAxis.maximum: slot.height + slot.y - knob.height + } + Rectangle { id: slot anchors.top: parent.top @@ -90,13 +99,6 @@ Item { onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - dragHandler.yAxis.minimum) * multiplier transformOrigin: Item.Center function setValue(value) { knob.y = dragHandler.yAxis.maximum - value / knob.multiplier } - DragHandler { - id: dragHandler - objectName: label.text + " DragHandler" - xAxis.enabled: false - yAxis.minimum: slot.y - yAxis.maximum: slot.height + slot.y - knob.height - } TapHandler { id: tap objectName: label.text + " TapHandler" |