# TextBox

## visual TextBox

#### new TextBox(options)

Source:
  - visual/TextBox.js, line 22
Mixes In:
  - ColorMixin

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`name` | String |  |  | the name used when logging messages from this stimulus
`win` | module:core.Window |  |  | the associated Window
`text` | string | <optional> | `""` | the text to be rendered
`font` | string | <optional> | `"Arial"` | the font family
`pos` | Array.<number> | <optional> | `[0, 0]` | the position of the center of the text
`color` | Color | <optional> | `Color('white')` | color of the text
`opacity` | number | <optional> | `1.0` | the opacity
`depth` | number | <optional> | `0` | the depth (i.e. the z order)
`contrast` | number | <optional> | `1.0` | the contrast
`units` | string | <optional> | `"norm"` | the units of the text size and position
`ori` | number | <optional> | `0.0` | the orientation (in degrees)
`letterHeight` | number | <optional> | `<default value>` | the height of the text
`bold` | boolean | <optional> | `false` | whether or not the text is bold
`italic` | boolean | <optional> | `false` | whether or not the text is italic
`anchor` | string | <optional> | `'left'` | horizontal alignment
`multiline` | boolean | <optional> | `false` | whether or not a multiline element is used
`autofocus` | boolean | <optional> | `true` | whether or not the first input should receive focus by default
`flipHoriz` | boolean | <optional> | `false` | whether or not to flip the text horizontally
`flipVert` | boolean | <optional> | `false` | whether or not to flip the text vertically
`fillColor` | Color | <optional> |  | fill color of the text-box
`languageStyle` | String | <optional> | `"LTR"` | sets the direction property of the text inputs. Possible values ["LTR", "RTL", "Arabic"]. "Arabic" is added for consistency with PsychoPy
`borderColor` | Color | <optional> |  | border color of the text-box
`clipMask` | PIXI.Graphics | <optional> | `null` | the clip mask
`autoDraw` | boolean | <optional> | `false` | whether or not the stimulus should be automatically drawn on every frame flip
`autoLog` | boolean | <optional> | `false` | whether or not to log
`fitToContent` | boolean | <optional> | `false` | whether or not to resize itself automaitcally to fit to the text content

### Extends

- VisualStim

### Members

#### (protected, static, readonly) _defaultLetterHeightMap

Source:
  - visual/TextBox.js, line 695

This map associates units to default letter height.

#### (protected, static, readonly) _defaultSizeMap

Source:
  - visual/TextBox.js, line 713

This map associates units to default sizes.

### Methods

#### (protected) _addEventListeners()

Source:
  - visual/TextBox.js, line 447

Add event listeners to text-box object. Method is called internally upon object construction.

#### (protected) _estimateBoundingBox()

Source:
  - visual/TextBox.js, line 560

Estimate the bounding box.

#### (protected) _getAnchor() → {Array.<number>}

Source:
  - visual/TextBox.js, line 664

Convert the anchor attribute into numerical values.

##### Returns:

- the anchor, as an array of numbers in [0,1]

Type
  Array.<number>

#### (protected) _getDefaultLetterHeight() → {number}

Source:
  - visual/TextBox.js, line 466

Get the default letter height given the stimulus' units.

##### Returns:

- the letter height corresponding to this stimulus' units.

Type
  number

#### (protected) _getTextInputOptions()

Source:
  - visual/TextBox.js, line 487

Get the TextInput options applied to the PIXI.TextInput.

#### (protected) _updateIfNeeded()

Source:
  - visual/TextBox.js, line 583
To Do:
  - take size into account

Update the stimulus, if necessary.

#### clear()

Source:
  - visual/TextBox.js, line 229

Clears the current text value.

#### getText() → {string}

Source:
  - visual/TextBox.js, line 334

For accessing the underlying input value.

##### Returns:

- the current text value of the underlying input element.

Type
  string

#### reset()

Source:
  - visual/TextBox.js, line 221

Clears the current text value or sets it back to match the placeholder.

#### setAlignment(alignment, logopt)

Source:
  - visual/TextBox.js, line 240

Setter for the alignment attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`alignment` | boolean |  | `left` | alignment of the text
`log` | boolean | <optional> | `false` | whether or not to log

#### setAnchor(anchor, logopt)

Source:
  - visual/TextBox.js, line 273

Setter for the anchor attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`anchor` | boolean |  | `center` | anchor of the textbox
`log` | boolean | <optional> | `false` | whether or not to log

#### setBorderColor(borderColor, logopt)

Source:
  - visual/TextBox.js, line 376

Setter for the borderColor attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`borderColor` | Color |  |  | border color of the text box
`log` | boolean | <optional> | `false` | whether or not to log

#### setColor(color, logopt)

Source:
  - visual/TextBox.js, line 350

Setter for the color attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`color` | boolean |  |  | color of the text
`log` | boolean | <optional> | `false` | whether or not to log

#### setFillColor(fillColor, logopt)

Source:
  - visual/TextBox.js, line 363

Setter for the fillColor attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`fillColor` | boolean |  |  | fill color of the text box
`log` | boolean | <optional> | `false` | whether or not to log

#### setFitToContent(fitToContent, logopt)

Source:
  - visual/TextBox.js, line 389

Setter for the fitToContent attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`fitToContent` | boolean |  |  | whether or not to autoresize textbox to fit to text content
`log` | boolean | <optional> | `false` | whether or not to log

#### setFont(font, logopt)

Source:
  - visual/TextBox.js, line 304

Set the font for textbox.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`font` | string |  | `Arial` | the font family
`log` | boolean | <optional> | `false` | whether to log

#### setLanguageStyle(languageStyle, logopt)

Source:
  - visual/TextBox.js, line 254

Setter for the languageStyle attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`languageStyle` | String |  | `LTR` | text direction in textbox, accepts values ["LTR", "RTL", "Arabic"]
`log` | boolean | <optional> | `false` | whether or not to log

#### setLetterHeight(fontSizeopt, logopt)

Source:
  - visual/TextBox.js, line 319

Set letterHeight (font size) for textbox.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`fontSize` | string | <optional> | `<default value>` | the size of the font
`log` | boolean | <optional> | `false` | whether to log

#### setSize(size, logopt)

Source:
  - visual/TextBox.js, line 406

Setter for the size attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`size` | boolean |  |  | whether or not to wrap the text at the given width
`log` | boolean | <optional> | `false` | whether or not to log

#### setText(text)

Source:
  - visual/TextBox.js, line 288

For tweaking the underlying input value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string |