aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/accessibility/content/Slider.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/accessibility/content/Slider.qml')
-rw-r--r--examples/quick/accessibility/content/Slider.qml30
1 files changed, 26 insertions, 4 deletions
diff --git a/examples/quick/accessibility/content/Slider.qml b/examples/quick/accessibility/content/Slider.qml
index fdbfd399b9..314c7af798 100644
--- a/examples/quick/accessibility/content/Slider.qml
+++ b/examples/quick/accessibility/content/Slider.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
@@ -46,17 +46,30 @@ import QtQuick 2.0
Rectangle {
id: slider
- property alias text : buttonText.text
+ property alias text: buttonText.text
Accessible.role: Accessible.Slider
- property int value // required
+ property int value : 5 // required
property int minimumValue : 0 // optional (default INT_MIN)
property int maximumValue : 20 // optional (default INT_MAX)
property int stepSize : 1 // optional (default 1)
- width: 30
+ width: 100
height: 30
+ border.color: "black"
+ border.width: 1
+ Rectangle {
+ id: indicator
+ x: 1
+ y: 1
+ height: parent.height - 2
+ width: ((parent.width - 2) / maximumValue) * value
+ color: "lightgrey"
+ Behavior on width {
+ NumberAnimation { duration: 50 }
+ }
+ }
Text {
id: buttonText
@@ -64,4 +77,13 @@ Rectangle {
anchors.centerIn: parent
font.pixelSize: parent.height * .5
}
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ var pos = mouse.x / slider.width * (maximumValue - minimumValue) + minimumValue
+ slider.value = pos
+ }
+ }
+ Keys.onLeftPressed: value > minimumValue ? value = value - stepSize : minimumValue
+ Keys.onRightPressed: value < maximumValue ? value = value + stepSize : maximumValue
}