- On today's menu: Native ButtonGestures (Double-Tap-Hold-Release) (LINK)
- Past menu 3: Double-Tap-Hold-Release button (LINK)
- Past menu 2: Loops of any Size (LINK)
- Past menu 1: Double-Tap buttons (see this post).
...
Double-Tap buttons
Inspired by Patch & dj_estrela, i decided to publish the basic code i used for all my double-tap modifications i've done. Hopefully you can implement it if you need something like this. The button distinguishes between a single tap (function call in the first timer) and a double tap (function call in the ButtonScriptAdapter) that interrupts the first timer before it has run out of time and made it's call.
ButtonScriptAdapter {
name: "BUTTON"
onPress: {
if (holdButton_countdown.running) {
tapButton_countdown.stop()
holdButton_countdown.stop()
// PLACE DOUBLE-TAP FUNCTION HERE
}
else holdButton_countdown.restart()
}
onRelease: {
if (holdButton_countdown.running) tapButton_countdown.restart()
}
}
Timer {
id: holdButton_countdown;
interval: 250
onTriggered: {
if (tapButton_countdown.running) {
// PLACE SINGLE-TAP FUNCTION HERE
}
}
}
Timer {
id: tapButton_countdown;
interval: 250
}
Wire { from: "%surface%.controllerButton"; to: "BUTTON" }
🦋
P.S: onTriggered executes when the timer reaches ZERO and doesn't execute if it gets stopped prematurely.
Edit: adjusted intro and title for new menus.