summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriano Rezende <adriano.1.rezende@nokia.com>2012-07-03 18:55:33 +0200
committerJens Bache-Wiig <jens.bache-wiig@nokia.com>2012-07-04 16:19:19 +0200
commitde26780ee0bb337c1ec6bcdb7bd25ef4c5f46227 (patch)
treebf94a27480c88dbb2c59d164af210d2c7fd12211
parent0df696bcdc3cd17a517e442530eb8c1718ebbbf8 (diff)
downloadqtquickcontrols-de26780ee0bb337c1ec6bcdb7bd25ef4c5f46227.tar.gz
Support key navigation for CheckBox and RadioButton
Change-Id: I9dbce4d9d8a6339b2424a94ce15afcec21896b86 Reviewed-by: Leonardo Sobral Cunha <leo.cunha@nokia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
-rw-r--r--components/CheckBox.qml18
-rw-r--r--components/RadioButton.qml2
2 files changed, 14 insertions, 6 deletions
diff --git a/components/CheckBox.qml b/components/CheckBox.qml
index c4c152de..7a254dd9 100644
--- a/components/CheckBox.qml
+++ b/components/CheckBox.qml
@@ -50,6 +50,7 @@ FocusScope {
property alias pressed: behavior.effectivePressed
property alias checked: behavior.checked
property alias containsMouse: behavior.containsMouse
+ property bool activeFocusOnPress: false
property string text
property string styleHint
@@ -95,11 +96,20 @@ FocusScope {
focus: true
anchors.fill: parent
checkable: true
- onClicked: {
- if (checkBox.activeFocusOnPress)
- checkBox.forceActiveFocus();
+ onClicked: checkBox.clicked();
+ onPressed: if (checkBox.activeFocusOnPress) checkBox.forceActiveFocus();
+ }
+
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Space && !event.isAutoRepeat && !behavior.pressed)
+ behavior.keyPressed = true;
+ }
+
+ Keys.onReleased: {
+ if (event.key == Qt.Key_Space && !event.isAutoRepeat && behavior.keyPressed) {
+ behavior.keyPressed = false;
+ checked = !checked;
checkBox.clicked();
}
}
- Keys.onSpacePressed: {clicked(); checked = !checked; }
}
diff --git a/components/RadioButton.qml b/components/RadioButton.qml
index 50def363..c6ff4a0f 100644
--- a/components/RadioButton.qml
+++ b/components/RadioButton.qml
@@ -69,6 +69,4 @@ CheckBox {
elide: Text.ElideRight
}
}
- Keys.onSpacePressed: {clicked(); checked = !checked; }
}
-