Skip to content

Textfield Block

The textfield block provides the ability to present the participant with a text field where they can enter text. A textfield block has to be specified within a response block. The structure of this block is summarised below.

Parameters

placeholder
Optional, defaults to an empty string.
String that specifies the placeholder text shown in the textfield.
sentence_completion

Optional, defaults to NONE.
Keyword taking the value of either NONE, LEFT, or RIGHT. This parameter specifies the position of the input field. It can be set to LEFT or RIGHT to position the input field next to a stimulus text to achieve the look of a sentence completion task.

If this parameter is set to LEFT or RIGHT, a text must also be specified. Also note that there will be no spacing between this text stimulus and the textfield by default, enabling word completion. If desired, you can include a trailing space in the text stimulus to visually separate the textfield.

lines

Optional, defaults to 1.
Integer that specifies the minimum vertical size of the input area. If this value is larger than 1, the user can resize the input area vertically beyond this minimum.

This parameter only controls the visual presentation of the input area and does not restrict the participant to enter a minimum or maximum amount of text. It can be used to indicate whether the participant is expected to enter a single word or phrase, or entire sentences.

If this parameter is larger than 1,

  • sentence_completion must be NONE
  • continue_on_enter will not take effect as the enter key is instead used to insert a newline in the input area
  • and therefore an alternative trial continuation option must be supplied, such as max_duration or a button response
required
Optional, defaults to true.
Boolean that controls whether input in the textfield is required.
continue_on_enter
Optional, defaults to true.
Boolean that controls whether the trial continues when the enter button is pressed in the textfield.

Example usage

The code below illustrates how the textfield block might be used.

experiment {
    trial {
        stimulus {
            text = "Roses are red "
        }
        response {
            textfield {
                placeholder = "and sometimes purple"
                sentence_completion = RIGHT
            }
        }
    }

    trial {
        stimulus {
            text = "Please describe your opinion on roses."
        }
        response {
            textfield {
                lines = 3
            }
            button
        }
    }
}
Back to top