Skip to main content

Class: FieldColourHsvSliders

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:190

Class for a colour input field that displays HSV slider widgets when clicked.

Extends​

Properties index​

PropertyDescription
ariaTypeNameThe ARIA-friendly label representation of this field's type.
borderRect_The rendered field's SVG border element.
clickTarget_The element the click handler is bound to.
constants_Constants associated with the source block's renderer.
DEFAULT_VALUETo overwrite the default value which is set in Field, directly update the prototype.
EDITABLEEditable fields usually show some sort of UI indicating they are editable. They will also be saved by the serializer.
enabled_Can the field value be changed using the editor on an editable block?
fieldGroup_The rendered field's SVG group element.
isDirty_Used to tell if the field needs to be rendered the next time the block is rendered. Colour fields are statically sized, and only need to be rendered at initialization.
isInitializedTrue once the field’s DOM has been created and it is safe to run ARIA updates in response to value changes.
maxDisplayLengthMaximum characters of text to display before adding an ellipsis.
menu_The dropdown menu.
menuGenerator_-
nameName of field. Unique within each block. Static labels are usually unnamed.
SERIALIZABLESerializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable.
sourceBlock_Block this field is attached to. Starts as null, then set in init.
textContent_The rendered field's text content element.
textElement_The rendered field's SVG text element.
validator_Validation function called when user edits an editable field.
value_-
valueWhenEditorWasOpenedThe intial value of the field when the user opened an editor to change its value. When the editor is disposed, an event will be fired that uses this as the event's oldValue.
visible_Is the field visible, or hidden due to the block being collapsed?
ARROW_CHAR-
BRIGHTNESS_SLIDER_MAXThe maximum value of the brightness slider range.
HUE_SLIDER_MAXThe maximum value of the hue slider range.
IMAGE_Y_OFFSETThe y offset from the top of the field to the top of the image, if an image is selected.
IMAGE_Y_PADDINGThe total vertical padding above and below an image.
NBSPNon-breaking space.
SATURATION_SLIDER_MAXThe maximum value of the saturation slider range.
SEPARATORMagic constant used to represent a separator in a list of dropdown items.
SKIP_SETUPA value used to signal when a field's constructor should not set the field's value or run configure_, and should allow a subclass to do that instead.
THUMB_RADIUSThe gradient control point positions should align with the center of the slider thumb when the corresponding colour is selected. When the slider is at the minimum or maximum value, the distance of center of the thumb from the edge of the track will be the thumb's radius, so that's how far the minimum and maximum control points should be.

Methods index​

MethodDescription
bindEvents_Bind events to the field. Can be overridden by subclasses if they need to do custom input handling.
canBeFocusedSee IFocusableNode.canBeFocused.
computeAriaLabelComputes a descriptive ARIA label to represent this field with configurable verbosity.
configure_Configure the field based on the given map of options.
createBorderRect_Create a field border rect element. Not to be overridden by subclasses. Instead modify the result of the function inside initView, or create a separate function to call.
createSVGArrow_Create an SVG based arrow.
createTextArrow_Create a tspan based arrow.
createTextElement_Create a field text element. Not to be overridden by subclasses. Instead, modify the result of the function inside initView, or create a separate function to call. Aria state is hidden; use the aria label for the field and/or containing block to expose content to screen readers. Text content for custom blocks can be set after creation.
disposeDispose of all DOM objects and events belonging to this editable field.
doClassValidation_Ensure that the input value is a valid colour.
doValueInvalid_Used to notify the field an invalid value was input. Can be overridden by subclasses, see FieldTextInput. No-op by default.
doValueUpdate_Updates the field's value to the given value.
dropdownDispose_Disposes of events and DOM-references belonging to the dropdown editor.
forceRerenderForce a rerender of the block that this field is installed on, which will rerender this field and adjust for any sizing changes. Other fields on the same block will not rerender, because their sizes have already been recorded.
getAbsoluteXY_Return the absolute coordinates of the top-left corner of this field. The origin (0,0) is the top-left corner of the page body.
getAriaTypeNameGets an ARIA-friendly label representation of this field's type.
getAriaValueGets an ARIA-friendly label representation of this field's value.
getBorderRectGets the border rectangle element.
getClickTarget_The element to bind the click handler to. If not set explicitly, defaults to the SVG root of the field. When this element is clicked on an editable field, the editor will open.
getConstantsGet the renderer constant provider.
getDisplayText_Get the text from this field to display on the block. May differ from getText due to ellipsis, and other formatting.
getFlipRtlReturns whether or not we should flip the field in RTL.
getFocusableElementSee IFocusableNode.getFocusableElement.
getFocusableTreeSee IFocusableNode.getFocusableTree.
getOptionsReturn a list of the options for this dropdown.
getSizeReturns the height and width of the field.
getSourceBlockGet the block this field is attached to.
getSvgRootGets the group element for this editable field. Used for measuring the size and for positioning.
getTextGet the text for this field. Used when the block is collapsed.
getText_Use the getText_ developer hook to override the field's text representation. Get the selected option text. If the selected option is an image we return the image alt text. If the selected option is an HTMLElement, return the title, ariaLabel, or innerText of the element.
getTextContentGets the text content.
getTextElementGets the text element.
getTooltipReturns the tooltip text for this field.
getValidatorGets the validation function for editable fields, or null if not set.
getValueGet the current value of the field.
initModelInitializes the model of the field after it has been installed on a block. No-op by default.
isClickableCheck whether this field defines the showEditor_ function.
isClickableInFlyoutCheck whether the field should be clickable while the block is in a flyout. The default is that fields are clickable in always-open flyouts such as the simple toolbox, but not in autoclosing flyouts such as the category toolbox. Subclasses may override this function to change this behavior. Note that isClickable must also return true for this to have any effect.
isCurrentlyEditableCheck whether this field is currently editable. Some fields are never EDITABLE (e.g. text labels). Other fields may be EDITABLE but may exist on non-editable blocks or be currently disabled.
isEnabledCheck whether this field's value can be changed using the editor when the source block is editable.
isFullBlockFieldDefines whether this field should take up the full block or not.
isOptionListDynamicReturns true if the option list is generated by a function. Otherwise false.
isSerializableCheck whether this field should be serialized by the XML renderer. Handles the logic for backwards compatibility and incongruous states.
isVisibleGets whether this editable field is visible or not.
loadLegacyStateLoads the given state using either the old XML hooks, if they should be used. Returns true to indicate loading has been handled, false otherwise.
onItemSelected_Handle the selection of an item in the dropdown menu.
onLocationChangeNotifies the field that it has changed locations.
onMouseDown_Handle a pointerdown event on a field.
onNodeBlurSee IFocusableNode.onNodeBlur.
onNodeFocusSee IFocusableNode.onNodeFocus.
onShortcutHandles the given keyboard shortcut.
performActionHandles the user acting on this field via keyboard navigation. Shows and focuses the field editor.
positionBorderRect_Position a field's border rect after a size change.
positionTextElement_Position a field's text element after a size change. This handles both LTR and RTL positioning.
recomputeAriaContextUpdates the ARIA roles and label for this field.
referencesVariablesWhether this field references any Blockly variables. If true it may need to be handled differently during serialization and deserialization, and this field's value must correspond to the ID of an existing variable. Subclasses may override this.
refreshVariableNameRefresh the variable name referenced by this field if this field references variables.
render_Updates the colour of the block to reflect whether this is a full block field or not.
repositionForWindowResizeA developer hook to reposition the WidgetDiv during a window resize. You need to define this hook if your field has a WidgetDiv that needs to reposition itself when the window is resized. For example, text input fields define this hook so that the input WidgetDiv can reposition itself on a window resize event. This is especially important when modal inputs have been disabled, as Android devices will fire a window resize event when the soft keyboard opens.
saveLegacyStateReturns a stringified version of the XML state, if it should be used. Otherwise this returns null, to signal the field should use its own serialization.
saveStateSaves this fields value as something which can be serialized to JSON. Should only be called by the serialization system.
setAriaTypeNameSets the ARIA-friendly label representation of this field's type.
setColoursSet a custom colour grid for this field.
setColumnsSets the number of columns on the grid. Updates the styling to reflect.
setEnabledSet whether this field's value can be changed using the editor when the source block is editable.
setOptionsUpdate the options on this dropdown. This will reset the selected item to the first item in the list.
setSourceBlockAttach this field to a block.
setTooltipSets the tooltip for this field.
setValidatorSets a new validation function for editable fields, or clears a previously set validator.
setValueUsed to change the value of the field. Handles validation and events. Subclasses should override doClassValidation_ and doValueUpdate_ rather than this method.
shouldAddBorderRect_Whether or not the dropdown should add a border rect.
showEditor_Create and show the colour field's editor.
toXmlSerializes this field's value to XML. Should only be called by Blockly.Xml.
trimOptionsFieldDropdown has complex behaviors for normalizing options that aren't applicable here. Instead, just return the options as-is.
updateEditableAdd or remove the UI indicating if this field is editable or not.
updateSize_Updates the size of the field based on whether it is a full block field or not.
validateOptionsValidates the data structure to be processed as an options list.

Constructors​

Constructor​

new FieldColourHsvSliders(
value?,
validator?,
config?
): FieldColourHsvSliders;

Defined in: plugins/field-colour/dist/field_colour.d.ts:37

Parameters​

ParameterTypeDescription
value?string | typeof SKIP_SETUPThe initial value of the field. Should be in '#rrggbb' format. Defaults to the first value in the default colour array. Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by subclasses that want to handle configuration and setting the field value after their own constructors have run).
validator?FieldColourValidatorA function that is called to validate changes to the field's value. Takes in a colour string & returns a validated colour string ('#rrggbb' format), or null to abort the change.
config?FieldColourConfigA map of options used to configure the field. See the [field creation documentation]https://www.npmjs.com/package/@blockly/field-colour for a list of properties this parameter supports.

Returns​

FieldColourHsvSliders

Inherited from​

FieldColour.constructor

Properties​

ariaTypeName​

protected ariaTypeName: string;

Defined in: plugins/field-colour/dist/field_colour.d.ts:22

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

Inherited from​

FieldColour.ariaTypeName


borderRect_​

protected borderRect_: SVGRectElement | null;

The rendered field's SVG border element.

Inherited from​

FieldColour.borderRect_


clickTarget_​

clickTarget_: SVGElement | null;

The element the click handler is bound to.

Inherited from​

FieldColour.clickTarget_


constants_​

protected constants_: ConstantProvider | null;

Constants associated with the source block's renderer.

Inherited from​

FieldColour.constants_


DEFAULT_VALUE​

DEFAULT_VALUE: string | null;

To overwrite the default value which is set in Field, directly update the prototype.

Example: FieldImage.prototype.DEFAULT_VALUE = null;

Inherited from​

FieldColour.DEFAULT_VALUE


EDITABLE​

EDITABLE: boolean;

Editable fields usually show some sort of UI indicating they are editable. They will also be saved by the serializer.

Inherited from​

FieldColour.EDITABLE


enabled_​

protected enabled_: boolean;

Can the field value be changed using the editor on an editable block?

Inherited from​

FieldColour.enabled_


fieldGroup_​

protected fieldGroup_: SVGGElement | null;

The rendered field's SVG group element.

Inherited from​

FieldColour.fieldGroup_


isDirty_​

protected isDirty_: boolean;

Defined in: plugins/field-colour/dist/field_colour.d.ts:21

Used to tell if the field needs to be rendered the next time the block is rendered. Colour fields are statically sized, and only need to be rendered at initialization.

Inherited from​

FieldColour.isDirty_


isInitialized​

isInitialized: boolean;

True once the field’s DOM has been created and it is safe to run ARIA updates in response to value changes.

Inherited from​

FieldColour.isInitialized


maxDisplayLength​

maxDisplayLength: number;

Maximum characters of text to display before adding an ellipsis.

Inherited from​

FieldColour.maxDisplayLength


protected menu_: Menu | null;

The dropdown menu.

Inherited from​

FieldColour.menu_


protected menuGenerator_?: MenuGenerator;

Inherited from​

FieldColour.menuGenerator_


name?​

name?: string;

Name of field. Unique within each block. Static labels are usually unnamed.

Inherited from​

FieldColour.name


SERIALIZABLE​

SERIALIZABLE: boolean;

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

Inherited from​

FieldColour.SERIALIZABLE


sourceBlock_​

protected sourceBlock_: Block | null;

Block this field is attached to. Starts as null, then set in init.

Inherited from​

FieldColour.sourceBlock_


textContent_​

protected textContent_: Text | null;

The rendered field's text content element.

Inherited from​

FieldColour.textContent_


textElement_​

protected textElement_: SVGTextElement | null;

The rendered field's SVG text element.

Inherited from​

FieldColour.textElement_


validator_​

protected validator_: FieldValidator<string> | null;

Validation function called when user edits an editable field.

Inherited from​

FieldColour.validator_


value_​

protected value_: string | null;

Inherited from​

FieldColour.value_


valueWhenEditorWasOpened​

protected valueWhenEditorWasOpened: string | null = null;

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:220

The intial value of the field when the user opened an editor to change its value. When the editor is disposed, an event will be fired that uses this as the event's oldValue.


visible_​

protected visible_: boolean;

Is the field visible, or hidden due to the block being collapsed?

Inherited from​

FieldColour.visible_


ARROW_CHAR​

static ARROW_CHAR: string;

Inherited from​

FieldColour.ARROW_CHAR


BRIGHTNESS_SLIDER_MAX​

protected readonly static BRIGHTNESS_SLIDER_MAX: 100 = 100;

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:198

The maximum value of the brightness slider range.


HUE_SLIDER_MAX​

protected readonly static HUE_SLIDER_MAX: 360 = 360;

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:192

The maximum value of the hue slider range.


IMAGE_Y_OFFSET​

protected static IMAGE_Y_OFFSET: number;

The y offset from the top of the field to the top of the image, if an image is selected.

Inherited from​

FieldColour.IMAGE_Y_OFFSET


IMAGE_Y_PADDING​

protected static IMAGE_Y_PADDING: number;

The total vertical padding above and below an image.

Inherited from​

FieldColour.IMAGE_Y_PADDING


NBSP​

readonly static NBSP: " " = "\u00A0";

Non-breaking space.

Inherited from​

FieldColour.NBSP


SATURATION_SLIDER_MAX​

protected readonly static SATURATION_SLIDER_MAX: 100 = 100;

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:195

The maximum value of the saturation slider range.


SEPARATOR​

readonly static SEPARATOR: "separator" = "separator";

Magic constant used to represent a separator in a list of dropdown items.

Inherited from​

FieldColour.SEPARATOR


SKIP_SETUP​

readonly static SKIP_SETUP: typeof SKIP_SETUP;

A value used to signal when a field's constructor should not set the field's value or run configure_, and should allow a subclass to do that instead.

Inherited from​

FieldColour.SKIP_SETUP


THUMB_RADIUS​

readonly static THUMB_RADIUS: 12 = 12;

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:207

The gradient control point positions should align with the center of the slider thumb when the corresponding colour is selected. When the slider is at the minimum or maximum value, the distance of center of the thumb from the edge of the track will be the thumb's radius, so that's how far the minimum and maximum control points should be.

Accessors​

size_​

Get Signature​

get protected size_(): Size;

Gets the size of this field. Because getSize() and updateSize() have side effects, this acts as a shim for subclasses which wish to adjust field bounds when setting/getting the size without triggering unwanted rendering or other side effects. Note that subclasses must override both get and set if either is overridden; the implementation may just call directly through to super, but it must exist per the JS spec.

Returns​

Size

Set Signature​

set protected size_(newValue): void;
Parameters​
ParameterType
newValueSize
Returns​

void

Inherited from​

FieldColour.size_

Methods​

bindEvents_()​

protected bindEvents_(): void;

Bind events to the field. Can be overridden by subclasses if they need to do custom input handling.

Returns​

void

Inherited from​

FieldColour.bindEvents_


canBeFocused()​

canBeFocused(): boolean;

See IFocusableNode.canBeFocused.

Returns​

boolean

Inherited from​

FieldColour.canBeFocused


computeAriaLabel()​

computeAriaLabel(includeTypeInfo?): string;

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.

If the field's value is empty then it will return a localized placeholder indicating that its value is empty. If this method returns an empty string, the output will be ignored when composing the block-level ARIA label. Make sure you want your label hidden from screenreaders before returning an empty string.

Parameters​

ParameterTypeDescription
includeTypeInfo?booleanWhether to include the field's type information in the returned label, if available.

Returns​

string

Inherited from​

FieldColour.computeAriaLabel


configure_()​

protected configure_(config): void;

Defined in: plugins/field-colour/dist/field_colour.d.ts:53

Configure the field based on the given map of options.

Parameters​

ParameterTypeDescription
configFieldColourConfigA map of options to configure the field based on.

Returns​

void

Inherited from​

FieldColour.configure_


createBorderRect_()​

protected createBorderRect_(): void;

Create a field border rect element. Not to be overridden by subclasses. Instead modify the result of the function inside initView, or create a separate function to call.

Returns​

void

Inherited from​

FieldColour.createBorderRect_


createSVGArrow_()​

protected createSVGArrow_(): void;

Create an SVG based arrow.

Returns​

void

Inherited from​

FieldColour.createSVGArrow_


createTextArrow_()​

protected createTextArrow_(): void;

Create a tspan based arrow.

Returns​

void

Inherited from​

FieldColour.createTextArrow_


createTextElement_()​

protected createTextElement_(): void;

Create a field text element. Not to be overridden by subclasses. Instead, modify the result of the function inside initView, or create a separate function to call. Aria state is hidden; use the aria label for the field and/or containing block to expose content to screen readers. Text content for custom blocks can be set after creation.

Returns​

void

Inherited from​

FieldColour.createTextElement_


dispose()​

dispose(): void;

Dispose of all DOM objects and events belonging to this editable field.

Returns​

void

Inherited from​

FieldColour.dispose


doClassValidation_()​

Call Signature​

protected doClassValidation_(newValue): string | null | undefined;

Defined in: plugins/field-colour/dist/field_colour.d.ts:110

Ensure that the input value is a valid colour.

Parameters​
ParameterTypeDescription
newValuestringThe input value.
Returns​

string | null | undefined

A valid colour, or null if invalid.

Inherited from​

FieldColour.doClassValidation_

Call Signature​

protected doClassValidation_(newValue?): string | null;

Defined in: plugins/field-colour/dist/field_colour.d.ts:111

Ensure that the input value is a valid colour.

Parameters​
ParameterTypeDescription
newValue?stringThe input value.
Returns​

string | null

A valid colour, or null if invalid.

Inherited from​

FieldColour.doClassValidation_


doValueInvalid_()​

protected doValueInvalid_(_invalidValue, _fireChangeEvent?): void;

Used to notify the field an invalid value was input. Can be overridden by subclasses, see FieldTextInput. No-op by default.

Parameters​

ParameterTypeDescription
_invalidValueanyThe input value that was determined to be invalid.
_fireChangeEvent?booleanWhether to fire a change event if the value changes.

Returns​

void

Inherited from​

FieldColour.doValueInvalid_


doValueUpdate_()​

protected doValueUpdate_(newValue): void;

Defined in: plugins/field-grid-dropdown/dist/index.d.ts:99

Updates the field's value to the given value.

Parameters​

ParameterTypeDescription
newValuestringThe new value for this field.

Returns​

void

Inherited from​

FieldColour.doValueUpdate_


protected dropdownDispose_(): void;

Defined in: plugins/field-grid-dropdown/dist/index.d.ts:93

Disposes of events and DOM-references belonging to the dropdown editor.

Returns​

void

Inherited from​

FieldColour.dropdownDispose_


forceRerender()​

forceRerender(): void;

Force a rerender of the block that this field is installed on, which will rerender this field and adjust for any sizing changes. Other fields on the same block will not rerender, because their sizes have already been recorded.

Returns​

void

Inherited from​

FieldColour.forceRerender


getAbsoluteXY_()​

protected getAbsoluteXY_(): Coordinate;

Return the absolute coordinates of the top-left corner of this field. The origin (0,0) is the top-left corner of the page body.

Returns​

Coordinate

Object with .x and .y properties.

Inherited from​

FieldColour.getAbsoluteXY_


getAriaTypeName()​

getAriaTypeName(): string | null;

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.

Returns​

string | null

An ARIA representation of the field's type or a default if it is unspecified.

Inherited from​

FieldColour.getAriaTypeName


getAriaValue()​

getAriaValue(): string;

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:657

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.

Returns​

string

An ARIA representation of the field's text.

Overrides​

FieldColour.getAriaValue


getBorderRect()​

protected getBorderRect(): SVGRectElement;

Gets the border rectangle element.

Returns​

SVGRectElement

The border rectangle element.

Throws​

An error if the border rectangle element is not defined.

Inherited from​

FieldColour.getBorderRect


getClickTarget_()​

protected getClickTarget_(): Element | null;

The element to bind the click handler to. If not set explicitly, defaults to the SVG root of the field. When this element is clicked on an editable field, the editor will open.

Returns​

Element | null

Element to bind click handler to.

Inherited from​

FieldColour.getClickTarget_


getConstants()​

getConstants(): ConstantProvider | null;

Get the renderer constant provider.

Returns​

ConstantProvider | null

The renderer constant provider.

Inherited from​

FieldColour.getConstants


getDisplayText_()​

protected getDisplayText_(): string;

Get the text from this field to display on the block. May differ from getText due to ellipsis, and other formatting.

Returns​

string

Text to display.

Inherited from​

FieldColour.getDisplayText_


getFlipRtl()​

getFlipRtl(): boolean;

Returns whether or not we should flip the field in RTL.

Returns​

boolean

True if we should flip in RTL.

Inherited from​

FieldColour.getFlipRtl


getFocusableElement()​

getFocusableElement(): HTMLElement | SVGElement;

See IFocusableNode.getFocusableElement.

Returns​

HTMLElement | SVGElement

Inherited from​

FieldColour.getFocusableElement


getFocusableTree()​

getFocusableTree(): IFocusableTree;

See IFocusableNode.getFocusableTree.

Returns​

IFocusableTree

Inherited from​

FieldColour.getFocusableTree


getOptions()​

getOptions(useCache?): MenuOption[];

Return a list of the options for this dropdown.

Parameters​

ParameterTypeDescription
useCache?booleanFor dynamic options, whether or not to use the cached options or to re-generate them.

Returns​

MenuOption[]

A non-empty array of option tuples: (human-readable text or image, language-neutral name).

Throws​

If generated options are incorrectly structured.

Inherited from​

FieldColour.getOptions


getSize()​

getSize(): Size;

Defined in: plugins/field-colour/dist/field_colour.d.ts:91

Returns the height and width of the field.

This should in general be the only place render_ gets called from.

Returns​

Size

Height and width.

Inherited from​

FieldColour.getSize


getSourceBlock()​

getSourceBlock(): Block | null;

Get the block this field is attached to.

Returns​

Block | null

The block containing this field.

Throws​

An error if the source block is not defined.

Inherited from​

FieldColour.getSourceBlock


getSvgRoot()​

getSvgRoot(): SVGGElement | null;

Gets the group element for this editable field. Used for measuring the size and for positioning.

Returns​

SVGGElement | null

The group element.

Inherited from​

FieldColour.getSvgRoot


getText()​

getText(): string;

Defined in: plugins/field-colour/dist/field_colour.d.ts:117

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

Returns​

string

Text representing the value of this field.

Inherited from​

FieldColour.getText


getText_()​

protected getText_(): string | null;

Use the getText_ developer hook to override the field's text representation. Get the selected option text. If the selected option is an image we return the image alt text. If the selected option is an HTMLElement, return the title, ariaLabel, or innerText of the element.

If you use HTMLElement options in Node.js and call this function, ensure that you are supplying an implementation of HTMLElement, such as through jsdom-global.

Returns​

string | null

Selected option text.

Inherited from​

FieldColour.getText_


getTextContent()​

protected getTextContent(): Text;

Gets the text content.

Returns​

Text

The text content.

Throws​

An error if the text content is not defined.

Inherited from​

FieldColour.getTextContent


getTextElement()​

protected getTextElement(): SVGTextElement;

Gets the text element.

Returns​

SVGTextElement

The text element.

Throws​

An error if the text element is not defined.

Inherited from​

FieldColour.getTextElement


getTooltip()​

getTooltip(): string;

Returns the tooltip text for this field.

Returns​

string

The tooltip text for this field.

Inherited from​

FieldColour.getTooltip


getValidator()​

getValidator(): FieldValidator<string> | null;

Gets the validation function for editable fields, or null if not set.

Returns​

FieldValidator<string> | null

Validation function, or null.

Inherited from​

FieldColour.getValidator


getValue()​

getValue(): string | null;

Get the current value of the field.

Returns​

string | null

Current value.

Inherited from​

FieldColour.getValue


initModel()​

initModel(): void;

Initializes the model of the field after it has been installed on a block. No-op by default.

Returns​

void

Inherited from​

FieldColour.initModel


isClickable()​

isClickable(): boolean;

Check whether this field defines the showEditor_ function.

Returns​

boolean

Whether this field is clickable.

Inherited from​

FieldColour.isClickable


isClickableInFlyout()​

isClickableInFlyout(autoClosingFlyout): boolean;

Check whether the field should be clickable while the block is in a flyout. The default is that fields are clickable in always-open flyouts such as the simple toolbox, but not in autoclosing flyouts such as the category toolbox. Subclasses may override this function to change this behavior. Note that isClickable must also return true for this to have any effect.

Parameters​

ParameterTypeDescription
autoClosingFlyoutbooleantrue if the containing flyout is an auto-closing one.

Returns​

boolean

Whether the field should be clickable while the block is in a flyout.

Inherited from​

FieldColour.isClickableInFlyout


isCurrentlyEditable()​

isCurrentlyEditable(): boolean;

Check whether this field is currently editable. Some fields are never EDITABLE (e.g. text labels). Other fields may be EDITABLE but may exist on non-editable blocks or be currently disabled.

Returns​

boolean

Whether this field is currently enabled, editable and on an editable block.

Inherited from​

FieldColour.isCurrentlyEditable


isEnabled()​

isEnabled(): boolean;

Check whether this field's value can be changed using the editor when the source block is editable.

Returns​

boolean

Whether this field is enabled.

Inherited from​

FieldColour.isEnabled


isFullBlockField()​

isFullBlockField(): boolean;

Defined in: plugins/field-colour/dist/field_colour.d.ts:71

Defines whether this field should take up the full block or not.

Returns​

boolean

True if this field should take up the full block. False otherwise.

Inherited from​

FieldColour.isFullBlockField


isOptionListDynamic()​

isOptionListDynamic(): boolean;

Returns​

boolean

True if the option list is generated by a function. Otherwise false.

Inherited from​

FieldColour.isOptionListDynamic


isSerializable()​

isSerializable(): boolean;

Check whether this field should be serialized by the XML renderer. Handles the logic for backwards compatibility and incongruous states.

Returns​

boolean

Whether this field should be serialized or not.

Inherited from​

FieldColour.isSerializable


isVisible()​

isVisible(): boolean;

Gets whether this editable field is visible or not.

Returns​

boolean

True if visible.

Inherited from​

FieldColour.isVisible


loadLegacyState()​

loadLegacyState(callingClass, state): boolean;

Loads the given state using either the old XML hooks, if they should be used. Returns true to indicate loading has been handled, false otherwise.

Parameters​

ParameterTypeDescription
callingClassFieldProtoThe class calling this method. Used to see if this has overridden any relevant hooks.
stateanyThe state to apply to the field.

Returns​

boolean

Whether the state was applied or not.

Inherited from​

FieldColour.loadLegacyState


onItemSelected_()​

protected onItemSelected_(menu, menuItem): void;

Handle the selection of an item in the dropdown menu.

Parameters​

ParameterTypeDescription
menuMenuThe Menu component clicked.
menuItemMenuItemThe MenuItem selected within menu.

Returns​

void

Inherited from​

FieldColour.onItemSelected_


onLocationChange()​

onLocationChange(_): void;

Notifies the field that it has changed locations.

Parameters​

ParameterTypeDescription
_CoordinateThe location of this field's block's top-start corner in workspace coordinates.

Returns​

void

Inherited from​

FieldColour.onLocationChange


onMouseDown_()​

protected onMouseDown_(e): void;

Handle a pointerdown event on a field.

Parameters​

ParameterTypeDescription
ePointerEventPointer down event.

Returns​

void

Inherited from​

FieldColour.onMouseDown_


onNodeBlur()​

onNodeBlur(): void;

See IFocusableNode.onNodeBlur.

Returns​

void

Inherited from​

FieldColour.onNodeBlur


onNodeFocus()​

onNodeFocus(): void;

See IFocusableNode.onNodeFocus.

Returns​

void

Inherited from​

FieldColour.onNodeFocus


onShortcut()​

onShortcut(_shortcut): boolean;

Handles the given keyboard shortcut.

Parameters​

ParameterTypeDescription
_shortcutKeyboardShortcutThe shortcut to be handled.

Returns​

boolean

True if the shortcut has been handled, false otherwise.

Inherited from​

FieldColour.onShortcut


performAction()​

performAction(): void;

Handles the user acting on this field via keyboard navigation. Shows and focuses the field editor.

Returns​

void

Inherited from​

FieldColour.performAction


positionBorderRect_()​

protected positionBorderRect_(): void;

Position a field's border rect after a size change.

Returns​

void

Inherited from​

FieldColour.positionBorderRect_


positionTextElement_()​

protected positionTextElement_(xOffset, contentWidth): void;

Position a field's text element after a size change. This handles both LTR and RTL positioning.

Parameters​

ParameterTypeDescription
xOffsetnumberx offset to use when positioning the text element.
contentWidthnumberThe content width.

Returns​

void

Inherited from​

FieldColour.positionTextElement_


recomputeAriaContext()​

recomputeAriaContext(): boolean;

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:429

Updates the ARIA roles and label for this field.

Returns​

boolean

Overrides​

FieldColour.recomputeAriaContext


referencesVariables()​

referencesVariables(): boolean;

Whether this field references any Blockly variables. If true it may need to be handled differently during serialization and deserialization, and this field's value must correspond to the ID of an existing variable. Subclasses may override this.

Returns​

boolean

True if this field has any variable references.

Inherited from​

FieldColour.referencesVariables


refreshVariableName()​

refreshVariableName(): void;

Refresh the variable name referenced by this field if this field references variables.

Returns​

void

Inherited from​

FieldColour.refreshVariableName


render_()​

protected render_(): void;

Defined in: plugins/field-colour/dist/field_colour.d.ts:96

Updates the colour of the block to reflect whether this is a full block field or not.

Returns​

void

Inherited from​

FieldColour.render_


repositionForWindowResize()​

repositionForWindowResize(): boolean;

A developer hook to reposition the WidgetDiv during a window resize. You need to define this hook if your field has a WidgetDiv that needs to reposition itself when the window is resized. For example, text input fields define this hook so that the input WidgetDiv can reposition itself on a window resize event. This is especially important when modal inputs have been disabled, as Android devices will fire a window resize event when the soft keyboard opens.

If you want the WidgetDiv to hide itself instead of repositioning, return false. This is the default behavior.

DropdownDivs already handle their own positioning logic, so you do not need to override this function if your field only has a DropdownDiv.

Returns​

boolean

True if the field should be repositioned, false if the WidgetDiv should hide itself instead.

Inherited from​

FieldColour.repositionForWindowResize


saveLegacyState()​

protected saveLegacyState(callingClass): string | null;

Returns a stringified version of the XML state, if it should be used. Otherwise this returns null, to signal the field should use its own serialization.

Parameters​

ParameterTypeDescription
callingClassFieldProtoThe class calling this method. Used to see if this has overridden any relevant hooks.

Returns​

string | null

The stringified version of the XML state, or null.

Inherited from​

FieldColour.saveLegacyState


saveState()​

saveState(_doFullSerialization?): any;

Saves this fields value as something which can be serialized to JSON. Should only be called by the serialization system.

Parameters​

ParameterTypeDescription
_doFullSerialization?booleanIf true, this signals to the field that if it normally just saves a reference to some state (eg variable fields) it should instead serialize the full state of the thing being referenced. See the field serialization docs for more information.

Returns​

any

JSON serializable state.

Inherited from​

FieldColour.saveState


setAriaTypeName()​

setAriaTypeName(ariaTypeName): void;

Sets the ARIA-friendly label representation of this field's type.

Implementations are responsible for, and encouraged to, set a localized version of the ARIA representation of the field's type. To that end, the provided value may contain message references of the form %{BKY_...} (e.g. %{BKY_MY_FIELD_ARIA_TYPE}), which are replaced with the corresponding Blockly.Msg value.

Parameters​

ParameterTypeDescription
ariaTypeNamestringAn ARIA representation of the field's type.

Returns​

void

Inherited from​

FieldColour.setAriaTypeName


setColours()​

setColours(colours, titles?): FieldColour;

Defined in: plugins/field-colour/dist/field_colour.d.ts:127

Set a custom colour grid for this field.

Parameters​

ParameterTypeDescription
coloursstring[]Array of colours for this block, or null to use default (FieldColour.COLOURS).
titles?string[]Optional array of colour tooltips, or null to use default (FieldColour.TITLES).

Returns​

FieldColour

Returns itself (for method chaining).

Inherited from​

FieldColour.setColours


setColumns()​

setColumns(columns): void;

Defined in: plugins/field-grid-dropdown/dist/index.d.ts:78

Sets the number of columns on the grid. Updates the styling to reflect.

Parameters​

ParameterTypeDescription
columnsnumberThe number of columns. Is rounded to an integer value and must be greater than 0. Invalid values are ignored.

Returns​

void

Inherited from​

FieldColour.setColumns


setEnabled()​

setEnabled(enabled): void;

Set whether this field's value can be changed using the editor when the source block is editable.

Parameters​

ParameterTypeDescription
enabledbooleanTrue if enabled.

Returns​

void

Inherited from​

FieldColour.setEnabled


setOptions()​

setOptions(menuGenerator): void;

Update the options on this dropdown. This will reset the selected item to the first item in the list.

Parameters​

ParameterTypeDescription
menuGeneratorMenuGeneratorThe array of options or a generator function.

Returns​

void

Inherited from​

FieldColour.setOptions


setSourceBlock()​

setSourceBlock(block): void;

Attach this field to a block.

Parameters​

ParameterTypeDescription
blockBlockThe block containing this field.

Returns​

void

Inherited from​

FieldColour.setSourceBlock


setTooltip()​

setTooltip(newTip): void;

Sets the tooltip for this field.

Parameters​

ParameterTypeDescription
newTipTipInfo | nullThe text for the tooltip, a function that returns the text for the tooltip, a parent object whose tooltip will be used, or null to display the tooltip of the parent block. To not display a tooltip pass the empty string.

Returns​

void

Inherited from​

FieldColour.setTooltip


setValidator()​

setValidator(handler): void;

Sets a new validation function for editable fields, or clears a previously set validator.

The validator function takes in the new field value, and returns validated value. The validated value could be the input value, a modified version of the input value, or null to abort the change.

If the function does not return anything (or returns undefined) the new value is accepted as valid. This is to allow for fields using the validated function as a field-level change event notification.

Parameters​

ParameterTypeDescription
handlerFieldValidator<string>The validator function or null to clear a previous validator.

Returns​

void

Inherited from​

FieldColour.setValidator


setValue()​

setValue(newValue, fireChangeEvent?): void;

Sealed

Used to change the value of the field. Handles validation and events. Subclasses should override doClassValidation_ and doValueUpdate_ rather than this method.

Parameters​

ParameterTypeDescription
newValueanyNew value.
fireChangeEvent?booleanWhether to fire a change event. Defaults to true. Should usually be true unless the change will be reported some other way, e.g. an intermediate field change event.

Returns​

void

Inherited from​

FieldColour.setValue


shouldAddBorderRect_()​

protected shouldAddBorderRect_(): boolean;

Whether or not the dropdown should add a border rect.

Returns​

boolean

True if the dropdown field should add a border rect.

Inherited from​

FieldColour.shouldAddBorderRect_


showEditor_()​

protected showEditor_(): void;

Defined in: plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts:252

Create and show the colour field's editor.

Returns​

void

Overrides​

FieldColour.showEditor_


toXml()​

toXml(fieldElement): Element;

Serializes this field's value to XML. Should only be called by Blockly.Xml.

Parameters​

ParameterTypeDescription
fieldElementElementThe element to populate with info about the field's state.

Returns​

Element

The element containing info about the field's state.

Inherited from​

FieldColour.toXml


trimOptions()​

protected trimOptions(options): object;

Defined in: plugins/field-colour/dist/field_colour.d.ts:45

FieldDropdown has complex behaviors for normalizing options that aren't applicable here. Instead, just return the options as-is.

Parameters​

ParameterTypeDescription
optionsMenuOption[]The options (colour swatches) to normalize.

Returns​

object

The colour swatches as-is.

options​
options: MenuOption[];

Inherited from​

FieldColour.trimOptions


updateEditable()​

updateEditable(): void;

Add or remove the UI indicating if this field is editable or not.

Returns​

void

Inherited from​

FieldColour.updateEditable


updateSize_()​

protected updateSize_(margin?): void;

Defined in: plugins/field-colour/dist/field_colour.d.ts:103

Updates the size of the field based on whether it is a full block field or not.

Parameters​

ParameterTypeDescription
margin?numbermargin to use when positioning the field.

Returns​

void

Inherited from​

FieldColour.updateSize_


validateOptions()​

protected validateOptions(options): void;

Validates the data structure to be processed as an options list.

Parameters​

ParameterTypeDescription
optionsMenuOption[]The proposed dropdown options.

Returns​

void

Throws​

If proposed options are incorrectly structured.

Inherited from​

FieldColour.validateOptions