getTimer(id).test.ended() (since beta 0.3) Tests whether the timer has ended. Example: [js highlight=”12″ try=”true”] newText(“start”, “Ready… go!”) .print() , newTimer(“hurry”, 1000) .start() , newButton(“click”, “Click me!”) .print() .wait() , getTimer(“hurry”) .test.ended() .success( newText(“slow”, “Too slow…”).print() ) .failure( newText(“fast”, “Good job!”).print() ) [/js] Adds a line of text saying Ready… go! to the screen, starts a …
Wiki Category Archives:
timer.settings.log
getTimer(id).settings.log() Will add a line to the results file each time the timer starts and each time it ends. Example: [js try=”true” highlight=”5″] newText(“pleasewait”, “Please wait 1s.”) .print() , newTimer(“wait”, 1000) .settings.log() .start() .wait() , newButton(“continue”, “Now click here to continue.”) .print() .wait() [/js] Adds the text Please wait 1s to the screen, starts a …
timer.settings.callback
getTimer(id).settings.callback( element ) or getTimer(id).settings.callback( function ) Warning: until PennController beta 0.2, this command has a bug that freezes the script Will execute the function or element command when the timer has finished running for the first time. Example: [js try=”true” highlight=”8″] newText(“start”, “Ready… go!”) .print() , newButton(“click”, “Click me!”) .print() , newTimer(“hurry”, 1000) .settings.callback( …
timer.wait
getTimer(id).wait() or getTimer(id).wait(“first”) or getTimer(id).wait( test ) Waits until the timer has finished running before evaluating and executing the next commands. If you call wait(“first”), then if the timer has already completed a full run before this command is evaluated, the next commands are evaluated and executed right away. If the timer was never completed …
timer.start
getTimer(id).start() Starts the timer. Example: [js highlight=”5″ try=”true”]newText(“pleasewait”, “Please wait 1s.”) .print() , newTimer(“wait”, 1000) .start() .wait() , getText(“pleasewait”) .remove() [/js] The code above adds the text Please wait 1s to the screen, starts a 1000ms timer and wait until it is done before removing the text.
textinput.test.text
getTextInput(id).test.text(“string”) or getScale(id).test.text( /RegExp/ ) Tests for a match with the text in the input box. Example: [js highlight=”7″ try=”true”]newTextInput(“haiku”, “hatsu shigure\nsaru mo komino o\nhoshige nari”) .settings.lines(3) .print() , newButton(“save”, “Save”) .print() .wait( getTextInput(“haiku”).test.text(/^.+[\r\n].+[\r\n].+$/) )[/js] Adds a 3-line input box to the screen containing a haiku (note the \n to insert linebreaks in the text) …
textinput.settings.text
getTextInput(id).settings.text(“string”) (since beta 0.3) (Re)sets the text in the input box. [js highlight=”11″ try=”true”]newTextInput(“poem”, “”) .settings.before( newText(“flowers”, “Violets are blue, roses are red, “) ) .print() , newButton(“validate”, “Validate”) .print() .wait() .remove() , getTextInput(“poem”) .settings.disable() .settings.text(“DISABLED”)[/js] Adds a one-line input box to the screen preceded with Violets are blue, roses are red, on its left, …
textinput.settings.once
getTextInput(id).settings.once() Disables the input box after the key enter/return has been pressed for the first time while editing. [js highlight=”3″ try=”true”]newTextInput(“poem”, “”) .settings.before( newText(“flowers”, “Violets are blue, roses are red, “) ) .settings.once() .print() .wait() [/js] Adds a one-line input box to the screen preceded with Violets are blue, roses are red, on its left …
textinput.settings.log
getTextInput(id).settings.log() or getTextInput(id).settings.log(“final”) (since beta 0.3) or getTextInput(id).settings.log(“validate”) (since beta 0.3) or getTextInput(id).settings.log(“first”) (since beta 0.3) or getTextInput(id).settings.log(“last”) (since beta 0.3) or getTextInput(id).settings.log(“all”) (since beta 0.3) or getTextInput(id).settings.log(“final”, “first”, …) (since beta 0.3) Will add a line to the result file containing the text in the input box at the moment of the event. By …
textinput.settings.lines
getTextInput(id).settings.lines( number ) Sets the maximum number of lines for the input box (1 by default). As a special case, you set it to 0 to remove the limit constraint. Example: [js highlight=”2″ try=”true”]newTextInput(“haiku”, “hatsu shigure\nsaru mo komino o\nhoshige nari”) .settings.lines(3) .print()[/js] Adds a 3-line input box to the screen containing a haiku (note the …