summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-10-24 17:41:44 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 15:16:11 +0100
commit6c5bcbf23928094338da90be2cd4a2787104cf03 (patch)
tree436d34c39532493e9c224f6194c3a3b54e986e0b /src
parent1eea75265d3f9d1162d5196a4c2f72176768aacb (diff)
downloadqtquickcontrols-6c5bcbf23928094338da90be2cd4a2787104cf03.tar.gz
qtquickcontrols-6c5bcbf23928094338da90be2cd4a2787104cf03.tar.bz2
qtquickcontrols-6c5bcbf23928094338da90be2cd4a2787104cf03.zip
Fix: Button does not toggle on keypress
This ensures that you can toggle a button using the space bar. task-number: QTBUG-33540 Change-Id: I7f665623fe113be11ba7e3f2c605e255d45e31a9 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/controls/Private/BasicButton.qml11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/controls/Private/BasicButton.qml b/src/controls/Private/BasicButton.qml
index 188e35ff..4c1eeb04 100644
--- a/src/controls/Private/BasicButton.qml
+++ b/src/controls/Private/BasicButton.qml
@@ -166,10 +166,13 @@ Control {
behavior.keyPressed = true;
}
+ onFocusChanged: if (!focus) behavior.keyPressed = false
+
Keys.onReleased: {
if (event.key === Qt.Key_Space && !event.isAutoRepeat && behavior.keyPressed) {
behavior.keyPressed = false;
__action.trigger(button)
+ behavior.toggle()
}
}
@@ -182,10 +185,14 @@ Control {
hoverEnabled: true
enabled: !keyPressed
+ function toggle() {
+ if (button.checkable && !button.action && !(button.checked && button.exclusiveGroup))
+ button.checked = !button.checked
+ }
+
onReleased: {
if (containsMouse) {
- if (button.checkable && !button.action && !(button.checked && button.exclusiveGroup))
- button.checked = !button.checked
+ toggle()
__action.trigger(button)
}
}