diff options
author | Jens Bache-Wiig <jens.bache-wiig@digia.com> | 2013-10-24 17:41:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-29 15:16:11 +0100 |
commit | 6c5bcbf23928094338da90be2cd4a2787104cf03 (patch) | |
tree | 436d34c39532493e9c224f6194c3a3b54e986e0b /src/controls | |
parent | 1eea75265d3f9d1162d5196a4c2f72176768aacb (diff) | |
download | qtquickcontrols-6c5bcbf23928094338da90be2cd4a2787104cf03.tar.gz |
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/controls')
-rw-r--r-- | src/controls/Private/BasicButton.qml | 11 |
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) } } |