From 7165800c731b6a4fa61946ff74304b105fb7f3e5 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Tue, 4 Feb 2014 22:56:33 +0100 Subject: [PATCH] PSlider: Live preview and prevent event stealing --- touch/PSlider.qml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/touch/PSlider.qml b/touch/PSlider.qml index bccb72e..478c1db 100644 --- a/touch/PSlider.qml +++ b/touch/PSlider.qml @@ -27,6 +27,9 @@ Rectangle { property real min: 0.0 property real max: 1.0 + property real displayedValue: mouseArea.pressed ? temporaryValue : value + property real temporaryValue + signal valueChangeRequested(real newValue) clip: true @@ -35,15 +38,23 @@ Rectangle { height: 50 * pgst.scalef MouseArea { + id: mouseArea anchors.fill: parent onClicked: slider.valueChangeRequested(min + (max - min) * (mouse.x / width)) + onPressed: { + slider.temporaryValue = (min + (max - min) * (mouse.x / width)); + } + onPositionChanged: { + slider.temporaryValue = (min + (max - min) * (mouse.x / width)); + } + preventStealing: true } Rectangle { id: fillBackground color: '#333333' height: parent.height * 0.8 - width: parent.width * (parent.value - parent.min) / (parent.max - parent.min) + width: parent.width * (parent.displayedValue - parent.min) / (parent.max - parent.min) anchors { verticalCenter: parent.verticalCenter