summaryrefslogtreecommitdiff
path: root/src/controls/Switch.qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-05-30 22:18:38 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-02 20:19:15 +0200
commitbe1df188f22757d30e474265082d12119dd46844 (patch)
treec17eba5ee91c32d3d0ffc15dbae69dfa41b08fd8 /src/controls/Switch.qml
parent35c11e02e01d19e1184a97be7e7aba9b1b936b79 (diff)
downloadqtquickcontrols-be1df188f22757d30e474265082d12119dd46844.tar.gz
Switch: add pressed-property and clicked() signal
Align with the basic functionality offered by CheckBox, and also required by certain styles. Change-Id: I53f2868f19a26e9abc0ed9c94d327edbe940429b Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'src/controls/Switch.qml')
-rw-r--r--src/controls/Switch.qml17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/controls/Switch.qml b/src/controls/Switch.qml
index bafb567c..639610bf 100644
--- a/src/controls/Switch.qml
+++ b/src/controls/Switch.qml
@@ -77,6 +77,14 @@ Control {
property bool checked: false
/*!
+ \qmlproperty bool Switch::pressed
+ \since QtQuick.Controls 1.3
+
+ This property is \c true when the control is pressed.
+ */
+ readonly property alias pressed: internal.pressed
+
+ /*!
This property is \c true if the control takes the focus when it is
pressed; \l{QQuickItem::forceActiveFocus()}{forceActiveFocus()} will be
called on the control.
@@ -88,6 +96,13 @@ Control {
*/
property ExclusiveGroup exclusiveGroup: null
+ /*!
+ \since QtQuick.Controls 1.3
+
+ This signal is emitted when the control is clicked.
+ */
+ signal clicked
+
Keys.onPressed: {
if (event.key === Qt.Key_Space && !event.isAutoRepeat)
checked = !checked;
@@ -126,6 +141,8 @@ Control {
checked = (handle.x === max) ? false : true
}
}
+
+ onClicked: root.clicked()
}
onCheckedChanged: {