TextInput element

description

Represents a text input box.

syntax

newTextInput(ELEMENT_NAME: string, DEFAULT_TEXT: string)
  • ELEMENT_NAME: The name of the newly-created element.
  • DEFAULT_TEXT : The default text that appears in the text input box.

since

beta 0.3

example(s)


$newTextInput("feedback", "Leave your feedback comments here.")
$    .log()
$    .lines(0)
$    .size(400, 200)
$    .print()
@,
@newButton("send", "Send")
@    .print()
@    .wait()
+ Adds a 400x200px multiple-line input box containg the text Leave your feedback comments here to the screen above a Send button and waits for a click on the button. The text in the box at the end of the trial will be saved in the results file.

Action commands

textinput.length

syntax

.length()

description

Limits the maximum number of characters that can be entered in the input box. 0 or lower means no limit (default setting). Note that linebreaks count as characters in the limit ( and ` `).

example

click to expand

@newTextInput("haiku", "hatsu shigure\nsaru mo komino o\nhoshige nari")
$    .length(45)
@    .lines(3)
@    .print()
  • Adds a 3-line input box limited to 45 characters to the screen, containing a haiku (note the \n to insert linebreaks in the text).
↑ back to top

textinput.lines

syntax

.lines()

description

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

click to expand

@newTextInput("haiku", "hatsu shigure\nsaru mo komino o\nhoshige nari")
$    .lines(3)
@    .print()
  • Adds a 3-line input box to the screen containing a haiku (note the \n to insert linebreaks in the text).
↑ back to top

textinput.log

syntax

.log()

description

Will add a line to the result file containing the text in the input box at the moment of the event. By default, leaving the parenthesis blank is equivalent to .log("final", "validate", "first").

example

click to expand

@newTextInput("feedback", "Leave your feedback comments here.")
$    .log()
@    .lines(0)
@    .size(400, 200)
@    .print()
@,
@newButton("send", "Send")
@    .print()
@    .wait()
  • Adds a 400x200px multiple-line input box containg the text Leave your feedback comments here to the screen above a Send button and waits for a click on the button. At least two lines will be added to the results file: one reporting the text in the box at the end of the trial, and one reporting the first key press. Additionally, you will see one line for each time the enter/return key was pressed.
↑ back to top

textinput.once

syntax

.once()

description

Disables the input box after the key enter/return has been pressed for the first time while editing.

example

click to expand

@newTextInput("poem", "")
@    .before( newText("flowers", "Violets are blue, roses are red, ") )
$    .once()
@    .print()
@    .wait()
  • Adds a one-line input box to the screen preceded with Violets are blue, roses are red, on its left and waits for a press on the enter/return key, after what the text can no longer be edited.
↑ back to top

textinput.text

syntax

.text()

description

(Re)sets the text in the input box.

example

click to expand

@newTextInput("poem", "")
@    .before( newText("flowers", "Violets are blue, roses are red, ") )
@    .print()
@,
@newButton("validate", "Validate")
@    .print()
@    .wait()
@    .remove()
@,
@getTextInput("poem")
@    .disable()
$    .text("DISABLED")
  • Adds a one-line input box to the screen preceded with Violets are blue, roses are red, on its left, and a button reading Validate. The input box can no longer be edited after a click, and its text is replaced with “DISABLED”.
↑ back to top

textinput.wait

syntax

.wait()

description

Waits until the enter/return key is pressed while entering text in the input box. Note that if you have a multiple-line input box, this can also mean insertion of a new line.

example

click to expand

@newTextInput("poem", "")
@    .before( newText("flowers", "Violets are blue, roses are red, ") )
@    .print()
$    .wait()
  • Adds a one-line input box to the screen preceded with Violets are blue, roses are red, on its left and waits for a press on the enter/return key.
↑ back to top


Test commands

textinput.test.text

syntax

.test.text()

description

Tests for a match with the text in the input box.

example

click to expand

@newTextInput("haiku", "hatsu shigure\nsaru mo komino o\nhoshige nari")
@    .lines(3)
@    .print()
@,
@newButton("save", "Save")
@    .print()
$    .wait( getTextInput("haiku").test.text(/^.+[\r\n].+[\r\n].+$/) )
  • Adds a 3-line input box to the screen containing a haiku (note the \n to insert linebreaks in the text) above a Save button and waits for a click on the button. The click is validated only if, at the moment of the click, the text in the input box contains three lines of text.
↑ back to top


Table of contents