Skip to main content

blockly > FieldCheckbox

FieldCheckbox class

Class for a checkbox field.

Signature:

export declare class FieldCheckbox extends Field<CheckboxBool>

Extends: Field<CheckboxBool>

Constructors

Constructor

Modifiers

Description

(constructor)(value, validator, config)

Constructs a new instance of the FieldCheckbox class

Properties

Property

Modifiers

Type

Description

CHECK_CHAR

static

readonly

(not declared)

Default character for the checkmark.

SERIALIZABLE

boolean

Serializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable.

value_

boolean | null

NOTE: The default value is set in Field, so maintain that value instead of overwriting it here or in the constructor.

Methods

Method

Modifiers

Description

configure_(config)

protected

Configure the field based on the given map of options.

doClassValidation_(newValue)

protected

Ensure that the input value is valid ('TRUE' or 'FALSE').

doValueUpdate_(newValue)

protected

Update the value of the field, and update the checkElement.

getAriaTypeName()

Gets an ARIA-friendly label representation of this field's type.

Implementations are responsible for, and encouraged to, return a localized version of the ARIA representation of the field's type.

getAriaValue()

Gets an ARIA-friendly label representation of this field's value.

Implementations are responsible for, and encouraged to, return a localized version of the ARIA representation of the field's value.

The FieldCheckbox implementation is not used for the actual ARIA label of the field, since the checked state is already included in the ARIA checked state, but it is used for the ARIA label of its source block.

getDisplayText_()

getText()

Get the text of this field. Used when the block is collapsed.

getValue()

Get the value of this field, either 'TRUE' or 'FALSE'.

getValueBoolean()

Get the boolean value of this field.

initView()

Create the block UI for this checkbox.

recomputeAriaContext()

Customizes the label and sets additional aria state.

render_()

setCheckCharacter(character)

Set the character used for the check mark.

showEditor_()

protected

Toggle the state of the checkbox on click.