# JSDoc: Class: TextBox

# Class: TextBox

## visual.TextBox(options)

#### new TextBox(options)

##### 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)
`height` | number | <optional> | 0.1 | 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
`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

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

### Extends

- VisualStim

### Members

#### (protected) _addEventListeners

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

Source:
  - visual/TextBox.js, line 442

#### (protected) _getDefaultLetterHeight

Get the default letter height given the stimulus' units.

Source:
  - visual/TextBox.js, line 458

#### clear

Clears the current text value.

Source:
  - visual/TextBox.js, line 222

#### getText

For accessing the underlying input value.

Source:
  - visual/TextBox.js, line 317

#### reset

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

Source:
  - visual/TextBox.js, line 211

#### setAlignment

Setter for the alignment attribute.

Source:
  - visual/TextBox.js, line 233

#### setAnchor

Setter for the anchor attribute.

Source:
  - visual/TextBox.js, line 249

#### setBorderColor

Setter for the borderColor attribute.

Source:
  - visual/TextBox.js, line 364

#### setColor

Setter for the color attribute.

Source:
  - visual/TextBox.js, line 334

#### setFillColor

Setter for the fillColor attribute.

Source:
  - visual/TextBox.js, line 349

#### setFitToContent

Setter for the fitToContent attribute.

Source:
  - visual/TextBox.js, line 379

#### setFont

Set the font for textbox.

Source:
  - visual/TextBox.js, line 284

#### setLetterHeight

Set letterHeight (font size) for textbox.

Source:
  - visual/TextBox.js, line 300

#### setSize

Setter for the size attribute.

Source:
  - visual/TextBox.js, line 398

#### setText

For tweaking the underlying input value.

Source:
  - visual/TextBox.js, line 267

### Methods

#### (protected) _estimateBoundingBox()

Estimate the bounding box.

Source:
  - visual/TextBox.js, line 553

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

Convert the anchor attribute into numerical values.

Source:
  - visual/TextBox.js, line 661

##### Returns:

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

Type
  Array.<number>