use onclicked
it gets canceled when it should
This commit is contained in:
parent
42aeaebb4e
commit
13a3d33681
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user