Skip to main content

blockly > FieldLabel

FieldLabel class

Class for a non-editable, non-serializable text field.

Signature:

export declare class FieldLabel extends Field<string>

Extends: Field<string>

Constructors

Constructor

Modifiers

Description

(constructor)(value, textClass, config)

Constructs a new instance of the FieldLabel class

Properties

Property

Modifiers

Type

Description

EDITABLE

boolean

Editable fields usually show some sort of UI indicating they are editable. This field should not.

maxDisplayLength

number

Text labels should not truncate.

Methods

Method

Modifiers

Description

computeAriaLabel(includeTypeInfo)

Computes a descriptive ARIA label to represent this field with configurable verbosity.

A 'verbose' label includes type information, if available, whereas a non-verbose label only contains the field's value.

Note that this will always return the latest representation of the field's label which may differ from any previously set ARIA label for the field itself. Implementations are largely responsible for ensuring that the field's ARIA label is set correctly at relevant moments in the field's lifecycle (such as when its value changes).

Finally, it is never guaranteed that implementations use the label returned by this method for their actual ARIA label. Some implementations may rely on other contexts to convey information like the field's value. Example: checkboxes represent their checked/non-checked status (i.e. value) through a separate ARIA property.

Unlike other built-in fields, FieldLabel does return an empty string when its value is empty. This is because empty labels are sometimes used for layout purposes.

configure_(config)

protected

doClassValidation_(newValue)

protected

Ensure that the input value casts to a valid string.

initView()

Create block UI for this label.

isLabelField()

setClass(cssClass)

Set the CSS class applied to the field's textElement_.