Hey, so I'm trying to write a pause button into a metronome loop, so that the user can pause the sound of a metronome (It's an edging metronome).
I'm drawing the button and adding a timeout on the button inside an each statement. It causes the button to flash because it's being redrawn on each iteration of the loop. Can I draw a button outside of the loop and have it not interfere with the continuation of the loop?
I'm really wanting to give the user 60 seconds to edge, present a button so that if they do it in time the metronome stops and returns a value, else script knows that user didn't edge in time.
This in essense is what I have.
Code:
(1..10).each {
def hasBeenPressed = showButton("Pause", 0.25);
if button pressed > 0 pause loop else ...
playBackgroundSound("tom.wav");
}
I would like to call the button outside the loop but not wait on the user clicking it, because havig the button outside the loop means the loop doesn't get run until pause is pressed.