Skip to content

Commit

Permalink
Fix input event order
Browse files Browse the repository at this point in the history
  • Loading branch information
gsurkov committed Sep 1, 2021
1 parent 37116df commit 1eaa35f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions application/components/StyledToolButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,32 @@ Item {

function setPressed() {
button.down = true;
pressed();
onButtonPressed();
}

function setReleased() {
button.down = false;
released();
onButtonReleased();
}

onPressed: {
function onButtonPressed() {
control.pressed();

if(!longTimer.running) {
longTimer.start();
}

if(shortTimer.running) {
shortTimer.stop();
if(releaseTimer.running) {
releaseTimer.stop();
}
}

onReleased: {
function onButtonReleased() {
releaseTimer.start();

if(longTimer.running) {
longTimer.stop();
shortTimer.start();
control.shortPress();
}

if(repeatTimer.running) {
Expand All @@ -60,15 +64,15 @@ Item {
icon.width: 32
icon.height: 32

onPressed: control.pressed()
onReleased: control.released()
onPressed: onButtonPressed()
onReleased: onButtonReleased()
}

Timer {
id: shortTimer
id: releaseTimer
repeat: false
interval: 1
onTriggered: control.shortPress()
onTriggered: control.released()
}

Timer {
Expand Down

0 comments on commit 1eaa35f

Please sign in to comment.