# Class: _Button

## LocusZoom_Widgets~_Button(parent)

Plots and panels may have a "toolbar" element suited for showing HTML widgets that may be interactive. When widgets need to incorporate a generic button, or additionally a button that generates a menu, this class provides much of the necessary framework. This widget is rarely used directly; it is usually used as part of the code for other widgets.

## Constructor

#### new _Button(parent)

##### Parameters:

Name | Type | Description
--- | --- | ---
`parent` | BaseWidget |

Source:
  - components/toolbar/widgets.js, line 187

### Members

#### color :String

Color of the button

##### Type:

- String

Source:
  - components/toolbar/widgets.js, line 230

#### (protected) html :String

HTML for the button to show.

##### Type:

- String

Source:
  - components/toolbar/widgets.js, line 217

#### menu :Object

Button Menu Object The menu is an HTML overlay that can appear below a button. It can contain arbitrary HTML and has logic to be automatically positioned and sized to behave more or less like a dropdown menu.

##### Type:

- Object

Source:
  - components/toolbar/widgets.js, line 267

#### onclick :function

##### Type:

- function

Source:
  - components/toolbar/widgets.js, line 539

#### onmouseout :function

##### Type:

- function

Source:
  - components/toolbar/widgets.js, line 527

#### onmouseover :function

##### Type:

- function

Source:
  - components/toolbar/widgets.js, line 515

#### parent :BaseWidget

##### Type:

- BaseWidget

Source:
  - components/toolbar/widgets.js, line 193

#### parent_panel :Panel

##### Type:

- Panel

Source:
  - components/toolbar/widgets.js, line 195

#### parent_plot :Plot

##### Type:

- Plot

Source:
  - components/toolbar/widgets.js, line 197

#### parent_svg :Plot|Panel

##### Type:

- Plot | Panel

Source:
  - components/toolbar/widgets.js, line 199

#### parent_toolbar :Toolbar|null|*

##### Type:

- Toolbar | null | *

Source:
  - components/toolbar/widgets.js, line 202

#### (protected) permanent :Boolean

Configuration when defining a button: track whether this widget should be allowed to keep open menu/button contents in response to certain events

##### Type:

- Boolean

Source:
  - components/toolbar/widgets.js, line 252

#### (protected) persist :Boolean

Track internal state on whether to keep showing the button/ menu contents at the moment

##### Type:

- Boolean

Source:
  - components/toolbar/widgets.js, line 245

#### selector :d3.selection

##### Type:

- d3.selection

Source:
  - components/toolbar/widgets.js, line 204

#### (protected) status :String

Button status (highlighted / disabled/ etc)

##### Type:

- String

Source:
  - components/toolbar/widgets.js, line 259

#### (protected) style :Object

Hash of arbitrary button styles to apply as {name: value} entries

##### Type:

- Object

Source:
  - components/toolbar/widgets.js, line 237

#### tag :String

Tag to use for the button (default: a)

##### Type:

- String

Source:
  - components/toolbar/widgets.js, line 210

#### (protected) title :String

Mouseover title text for the button to show

##### Type:

- String

Source:
  - components/toolbar/widgets.js, line 224

### Methods

#### disable(bool) → {Button}

Toggle whether the button is disabled

##### Parameters:

Name | Type | Description
--- | --- | ---
`bool` | boolean | If provided, explicitly set disabled state

Source:
  - components/toolbar/widgets.js, line 499

##### Returns:

Type
  Button

#### getClass() → {string}

Method to generate a CSS class string

Source:
  - components/toolbar/widgets.js, line 459

##### Returns:

Type
  string

#### hide() → {Button}

Hide the button by removing it from the DOM (may be overridden by current persistence setting)

Source:
  - components/toolbar/widgets.js, line 634

##### Returns:

Type
  Button

#### highlight(bool) → {Button}

Toggle whether the button is highlighted

##### Parameters:

Name | Type | Description
--- | --- | ---
`bool` | boolean | If provided, explicitly set highlighted state

Source:
  - components/toolbar/widgets.js, line 480

##### Returns:

Type
  Button

#### postUpdate() → {Button}

Hook for any behavior to be added/changed after the button has been re-rendered

Source:
  - components/toolbar/widgets.js, line 626

##### Returns:

Type
  Button

#### preUpdate() → {Button}

Hook for any actions or state cleanup to be performed before rerendering

Source:
  - components/toolbar/widgets.js, line 595

##### Returns:

Type
  Button

#### setColor(color) → {Button}

Set the color associated with this button

##### Parameters:

Name | Type | Description
--- | --- | ---
`color` | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | Any selection not in the preset list will be replaced with gray.

Source:
  - components/toolbar/widgets.js, line 406

##### Returns:

Type
  Button

#### setHtml(html) → {Button}

Specify the HTML content of this button. WARNING: The string provided will be inserted into the document as raw markup; XSS mitigation is the responsibility of each button implementation.

##### Parameters:

Name | Type | Description
--- | --- | ---
`html` | String |

Source:
  - components/toolbar/widgets.js, line 569

##### Returns:

Type
  Button

#### setPermanent(bool) → {Button}

Allow code to change whether the button is allowed to be `permanent`

##### Parameters:

Name | Type | Description
--- | --- | ---
`bool` | boolean |

Source:
  - components/toolbar/widgets.js, line 422

##### Returns:

Type
  Button

#### setStatus(status)

Change button state

##### Parameters:

Name | Type | Description
--- | --- | ---
`status` | 'highlighted' | 'disabled' | '' |

Source:
  - components/toolbar/widgets.js, line 468

#### setStyle(style) → {Button}

Set a collection of custom styles to be used by the button

##### Parameters:

Name | Type | Description
--- | --- | ---
`style` | Object | Hash of {name:value} entries

Source:
  - components/toolbar/widgets.js, line 448

##### Returns:

Type
  Button

#### setTitle(title) → {Button}

Set the mouseover title text for the button (if any)

##### Parameters:

Name | Type | Description
--- | --- | ---
`title` | String | Simple text to display

Source:
  - components/toolbar/widgets.js, line 555

##### Returns:

Type
  Button

#### shouldPersist() → {Boolean}

Determine whether the button/menu contents should persist in response to a specific event

Source:
  - components/toolbar/widgets.js, line 439

##### Returns:

Type
  Boolean

#### show()

Show the button, including creating DOM elements if necessary for first render

Source:
  - components/toolbar/widgets.js, line 580

#### update() → {Button}

Update button state and contents, and fully rerender

Source:
  - components/toolbar/widgets.js, line 603

##### Returns:

Type
  Button