# ButtonStim

## visual ButtonStim

ButtonStim visual stimulus.

## Constructor

#### new ButtonStim(options)

Source:
  - visual/ButtonStim.js, line 18

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`win` | module:core.Window |  |  | the associated Window
`name` | String |  |  | the name used when logging messages from this stimulus
`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
`anchor` | string | <optional> | `"center"` | horizontal alignment
`units` | string | <optional> | `"norm"` | the units of the text size and position
`color` | Color | <optional> | `Color("white")` | the background color
`fillColor` | Color | <optional> | `Color("darkgrey")` | the fill color
`borderColor` | Color | <optional> | `Color("white")` | the border color
`borderWidth` | Color | <optional> | `0` | the border width
`opacity` | number | <optional> | `1.0` | the opacity
`letterHeight` | number | <optional> |  | the height of the text
`bold` | boolean | <optional> | `true` | whether or not the text is bold
`italic` | boolean | <optional> | `false` | whether or not the text is italic
`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

### Extends

- TextBox

### Members

#### isClicked

Source:
  - visual/ButtonStim.js, line 134

Is this button currently being clicked on?

#### numClicks

Source:
  - visual/ButtonStim.js, line 124

How many times has this button been clicked on?

### Methods

#### (protected) _addEventListeners()

Source:
  - visual/TextBox.js, line 452
Overrides:
  - TextBox#_addEventListeners

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

#### (protected) _estimateBoundingBox()

Source:
  - visual/TextBox.js, line 571
Inherited From:
  - TextBox#_estimateBoundingBox

Estimate the bounding box.

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

Source:
  - visual/TextBox.js, line 675
Overrides:
  - TextBox#_getAnchor

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 471
Overrides:
  - TextBox#_getDefaultLetterHeight

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 492
Overrides:
  - TextBox#_getTextInputOptions

Get the TextInput options applied to the PIXI.TextInput.

#### (protected) _updateIfNeeded()

Source:
  - visual/TextBox.js, line 594
Overrides:
  - TextBox#_updateIfNeeded
To Do:
  - take size into account

Update the stimulus, if necessary.

#### clear()

Source:
  - visual/TextBox.js, line 229
Overrides:
  - TextBox#clear

Clears the current text value.

#### getText() → {string}

Source:
  - visual/TextBox.js, line 339
Overrides:
  - TextBox#getText

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
Overrides:
  - TextBox#reset

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

#### setAlignment(alignment, logopt)

Source:
  - visual/TextBox.js, line 240
Overrides:
  - TextBox#setAlignment

Setter for the alignment attribute.

##### Parameters:

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

#### setAnchor(anchor, logopt)

Source:
  - visual/TextBox.js, line 278
Overrides:
  - TextBox#setAnchor

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 381
Overrides:
  - TextBox#setBorderColor

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 355
Overrides:
  - TextBox#setColor

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 368
Overrides:
  - TextBox#setFillColor

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 394
Overrides:
  - TextBox#setFitToContent

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 309
Overrides:
  - TextBox#setFont

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 259
Overrides:
  - TextBox#setLanguageStyle

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 324
Overrides:
  - TextBox#setLetterHeight

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 411
Overrides:
  - TextBox#setSize

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 293
Overrides:
  - TextBox#setText

For tweaking the underlying input value.

##### Parameters:

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