Button element

description

Represents a clickable button.

syntax

newButton(ELEMENT_NAME: string, BUTTON_TEXT: string)
  • ELEMENT_NAME: The name of the newly-created element.
  • BUTTON_TEXT : The text that appears on the button.

since

beta 0.3

example(s)

```javascript newButton("click", "Click me!") .print() .wait() ``` Prints a `Button` to the screen and waits for it to be clicked.

Action commands

button.callback

syntax

.callback()

description

Will execute the command(s) whenever the button is clicked.

example

click to expand

@newVideo("skate", "skate.mp4")
@    .print()
@,
@newButton("(Re)play")
$    .callback( 
$        getVideo("skate")
$           .stop()
$            .play()
$    )
@    .print()
  • Adds onto the page a video and a button which, whenever clicked, starts or restarts playing the video from the beginning.
↑ back to top

button.click

syntax

.click()

description

Simulates a click on the button.

example

click to expand

@newKey(" ")
@    .callback(
@        getButton("continue")
$            .click()
@    )
@,
@newButton("continue", "Continue")
@    .print()
@    .wait()
  • Creates a Key element associated with the spacebar which, whenever pressed, will simulate a click on the continue button added below it, then will wait until the button is clicked (or thus until the spacebar is pressed) before proceeding.
↑ back to top

button.log

syntax

.log()

description

Adds a line to the results file each time the button is clicked.

example

click to expand

@newButton("word", "It's a word!")
$    .log()
@    .once()
@    .print()
@,
@newAudio("sound", "sound.wav")
@    .play()
@    .wait()
  • Adds a button to the screen, plays the audio file sound.wav and proceeds when the audio is done playing. The button can only be clicked once (see .once), and if it is, it will add a line in the results file.
↑ back to top

button.once

syntax

.once()

description

Disables the button right after it is clicked for the first time.

example

click to expand

@newButton("test", "It's a test!")
@    .log()
$    .once()
@    .print()
@,
@newAudio("sound", "test.mp3")
@    .play()
@    .wait()
  • Adds a button to the screen, plays the audio file test.mp3 and proceeds when the audio is done playing. The button can only be clicked once, and if it is, it will add a line in the results file (see .log).
↑ back to top

button.wait

syntax

.wait()

description

Waits until the button it clicked before evaluating and executing the next commands.

example

click to expand

@newTextInput("poem", "")
@    .before( newText("Violets are blue, roses are red,") )
@    .print()
@,
@newButton("validation", "Validate")
@    .print()
@    .wait( getTextInput("poem").testNot.text("") )
  • Adds an input box to the screen preceded with Violets are blue, roses are red, on its left, and a button with the text Validate below it. Proceeds only when the button is clicked and the input box is not empty.
↑ back to top


Test commands

button.test.clicked

syntax

.test.clicked()

description

Tests whether the button was ever clicked before.

example

click to expand

@newButton("test", "It's a test!")
@    .log()
@    .once()
@    .print()
$    .test.clicked()
@,
@newAudio("sound", "test.mp3")
@    .play()
@    .wait()
↑ back to top


Table of contents