Home

# Class goog.ui.Checkbox

3-state checkbox widget. Fires CHECK or UNCHECK events before toggled and CHANGE event after toggled by user. The checkbox can also be enabled/disabled and get focused and highlighted.

extends goog.ui.Control

Instance Method Summary
| `enterDocument()` Configures the component after its DOM has been rendered, and sets up event handling. Overrides {@link goog.ui.Component#enterDocument}.
| `getChecked() ⇒ ?goog.ui.Checkbox.State`
| `handleClickOrSpace_(!goog.events.BrowserEvent e)` Handles the click event.
| `handleKeyEventInternal(?goog.events.KeyEvent e) ⇒ boolean` Attempts to handle a keyboard event; returns true if the event was handled, false otherwise. Considered protected; should only be used within this package and by subclasses.
| `isChecked() ⇒ boolean`
| `isUnchecked() ⇒ boolean`
| `isUndetermined() ⇒ boolean`
| `setChecked(?boolean checked)` Sets the checked state of the checkbox.
| `setCheckedInternal(?goog.ui.Checkbox.State checked)` Sets the checked state for the checkbox. Unlike {@link #setChecked}, doesn't update the checkbox's DOM. Considered protected; to be called only by renderer code during element decoration.
| `setEnabled(boolean enable)` Fix for tabindex not being updated so that disabled checkbox is not focusable. In particular this fails in Chrome. Note: in general tabIndex=-1 will prevent from keyboard focus but enables mouse focus, however in this case the control class prevents mouse focus.
| `setLabel(?Element label)` Binds an HTML element to the checkbox which if clicked toggles the checkbox. Behaves the same way as the 'label' HTML tag. The label element has to be the direct or non-direct ancestor of the checkbox element because it will get the focus when keyboard support is implemented.

`toggle()`

Toggles the checkbox. State transitions:

- unchecked -> checked
- undetermined -> checked
- checked -> unchecked