From 13a3d3368184595211eafbb15eccabe171f306d1 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 28 Nov 2011 21:41:26 +0100 Subject: [PATCH] use onclicked it gets canceled when it should --- .../platformcomponents/touch/ToolButton.qml | 21 +++++++------------ .../plasmacomponents/qml/Button.qml | 21 ++++++++----------- .../plasmacomponents/qml/ToolButton.qml | 21 +++++++------------ 3 files changed, 25 insertions(+), 38 deletions(-) diff --git a/declarativeimports/plasmacomponents/platformcomponents/touch/ToolButton.qml b/declarativeimports/plasmacomponents/platformcomponents/touch/ToolButton.qml index 05aa17851..ef66cfcea 100644 --- a/declarativeimports/plasmacomponents/platformcomponents/touch/ToolButton.qml +++ b/declarativeimports/plasmacomponents/platformcomponents/touch/ToolButton.qml @@ -59,26 +59,21 @@ Item { // disabled buttons opacity: enabled ? 1.0 : 0.5 - Keys.onSpacePressed: internal.pressButton() - Keys.onReturnPressed: internal.pressButton() + Keys.onSpacePressed: internal.userPressed = true + Keys.onReturnPressed: internal.userPressed = true Keys.onReleased: { + internal.userPressed = false if (event.key == Qt.Key_Space || event.key == Qt.Key_Return) - internal.releaseButton() + internal.clickButton() } QtObject { id: internal property bool userPressed: false - function pressButton() + function clickButton() { - userPressed = true - } - - function releaseButton() - { - userPressed = false if (!button.enabled) { return } @@ -229,9 +224,9 @@ Item { anchors.fill: parent hoverEnabled: true - onPressed: internal.pressButton(); - - onReleased: internal.releaseButton(); + onPressed: internal.userPressed = true + onReleased: internal.userPressed = false + onClicked: internal.clickButton() } } diff --git a/declarativeimports/plasmacomponents/qml/Button.qml b/declarativeimports/plasmacomponents/qml/Button.qml index 6912658eb..0038c0a4a 100644 --- a/declarativeimports/plasmacomponents/qml/Button.qml +++ b/declarativeimports/plasmacomponents/qml/Button.qml @@ -60,12 +60,7 @@ Item { && button.parent.exclusive } - function pressButton() - { - userPressed = true - } - - function releaseButton() + function clickButton() { userPressed = false if (!button.enabled) { @@ -81,12 +76,13 @@ Item { } } - Keys.onSpacePressed: internal.pressButton() - Keys.onReturnPressed: internal.pressButton() + Keys.onSpacePressed: internal.userPressed = true + Keys.onReturnPressed: internal.userPressed = true Keys.onReleased: { + internal.userPressed = false if (event.key == Qt.Key_Space || event.key == Qt.Key_Return) - internal.releaseButton(); + internal.clickButton(); } ButtonShadow { @@ -210,8 +206,9 @@ Item { anchors.fill: parent hoverEnabled: true - onPressed: internal.pressButton() - onReleased: internal.releaseButton() - onCanceled: internal.releaseButton() + onPressed: internal.userPressed = true + onReleased: internal.userPressed = false + onCanceled: internal.userPressed = false + onClicked: internal.clickButton() } } \ No newline at end of file diff --git a/declarativeimports/plasmacomponents/qml/ToolButton.qml b/declarativeimports/plasmacomponents/qml/ToolButton.qml index accb809c4..4d55599e0 100644 --- a/declarativeimports/plasmacomponents/qml/ToolButton.qml +++ b/declarativeimports/plasmacomponents/qml/ToolButton.qml @@ -59,12 +59,13 @@ Item { // disabled buttons opacity: enabled ? 1.0 : 0.5 - Keys.onSpacePressed: internal.pressButton() - Keys.onReturnPressed: internal.pressButton() + Keys.onSpacePressed: internal.userPressed = true + Keys.onReturnPressed: internal.userPressed = true Keys.onReleased: { + internal.userPressed = false if (event.key == Qt.Key_Space || event.key == Qt.Key_Return) - internal.releaseButton() + internal.clickButton() } onActiveFocusChanged: { @@ -81,14 +82,8 @@ Item { id: internal property bool userPressed: false - function pressButton() + function clickButton() { - userPressed = true - } - - function releaseButton() - { - userPressed = false if (!button.enabled) { return } @@ -186,9 +181,9 @@ Item { anchors.fill: parent hoverEnabled: true - onPressed: internal.pressButton(); - - onReleased: internal.releaseButton(); + onPressed: internal.userPressed = true + onReleased: internal.userPressed = false + onClicked: internal.clickButton() onEntered: { if (!flat) {