timer.callback
description
Warning: until PennController beta 0.2, this command has a bug that freezes the script
syntax
getTimer(ELEMENT_NAME).callback(element)
-
element
:
alternate(s)
-
getTimer(ELEMENT_NAME).callback( function )
notes
- Will execute the function or element command when the timer has finished running for the first time.
example(s)
@
@newText("start", "Ready... go!")
@ .print()
@,
@newButton("click", "Click me!")
@ .print()
@,
@newTimer("hurry", 1000)
$ .callback( getButton("click").remove() )
@ .start()
@,
@getButton("click")
@ .wait()
@,
@newText("success", "You're quick!")
@ .print()
- Adds a line of text saying Ready… go! to the screen above a button reading Click me!, then starts a 1s timer and waits for a click on the button. After 1s, the button disappears. The text You’re quick! appears on the page after a click on the button. If the button was not clicked within 1s, the text does not show up and the script waits for a click forever (since the button no longer can be clicked). If the button was clicked, then the button’s
wait
command is validated and the text shows up (the button will still disappear after one second, as specified in the callback).