Skip to main content

Class: FieldSlider

Defined in: plugins/field-slider/src/field_slider.ts:31

Slider field.

Extends​

  • FieldNumber

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.
fullBlockClickTarget_Whether the field should consider the whole parent block to be its click target.
htmlInput_The HTML input element.
isBeingEdited_True if the field's value is currently being edited via the UI.
isDirty_Does this block need to be re-rendered?
isTextValid_True if the value currently displayed in the field's editory UI is valid.
max_The maximum value this number field can contain.
maxDisplayLengthMaximum characters of text to display before adding an ellipsis.
min_The minimum value this number field can contain.
nameName of field. Unique within each block. Static labels are usually unnamed.
precision_The multiple to which this fields value is rounded.
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.
spellcheck_Don't spellcheck numbers. Our validator does a better job.
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_-
valueWhenEditorWasOpened_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_Is the field visible, or hidden due to the block being collapsed?
warningIconThe warning icon to display on invalid input
workspace_The workspace that this field belongs to.
BORDERRADIUSPixel size of input border radius. Should match blocklyText's border-radius in CSS.
NBSPNon-breaking space.
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.

Methods index​

MethodDescription
applyColourUpdates text field to match the colour/style of the block.
bindEvents_Bind events to the field. Can be overridden by subclasses if they need to do custom input handling.
bindInputEvents_Bind handlers for user input on the text input field's editor.
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.
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.
createWarningIconCreates the DOM elements for the invalid input warning icon.
disposeDispose of all DOM objects and events belonging to this editable field.
doClassValidation_Ensure that the input value is a valid number (must fulfill the constraints placed on the field).
doValueInvalid_Called by setValue if the text input is not valid. If the field is currently being edited it reverts value of the field to the previous value while allowing the display text to be handled by the htmlInput_.
doValueUpdate_Called by setValue if the text input is valid. Updates the value of the field, and updates the text of the field if it is not currently being edited (i.e. handled by the htmlInput_).
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.
fromXmlSets the field's value based on the given XML element. Should only be called by Blockly.Xml.
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.
getEditorText_Transform the provided value into a text to show in the HTML input. Override this method if the field's HTML input representation is different than the field's value. This should be coupled with an override of getValueFromEditorText_.
getFlipRtlReturns whether or not we should flip the field in RTL.
getFocusableElementSee IFocusableNode.getFocusableElement.
getFocusableTreeSee IFocusableNode.getFocusableTree.
getMaxReturns the current maximum value this field can contain. Default is Infinity.
getMinReturns the current minimum value this field can contain. Default is -Infinity.
getPrecisionReturns the current precision of this field. The precision being the number to which the field's value is rounded. A precision of 0 means that the value is not rounded.
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 from this field. Override getText_ to provide a different behavior than simply casting the value to a string.
getText_Use the getText_ developer hook to override the field's text representation. When we're currently editing, return the current HTML value instead. Otherwise, return null which tells the field to use the default behaviour (which is a string cast of the field's value).
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.
getValueFromEditorText_Transform the text received from the HTML input into a value to store in this field. Override this method if the field's HTML input representation is different than the field's value. This should be coupled with an override of getEditorText_.
initModelInitializes the model of the field after it has been installed on a block. No-op by default.
initViewInitialize the field's DOM.
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.
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.
loadStateSets the field's state based on the given state value. Should only be called by the serialization system.
onFinishEditing_A callback triggered when the user is done editing the field via the UI.
onHtmlInputKeyDown_Handle key down to the editor.
onLocationChangeNotifies the field that it has changed locations. Moves the widget div to be in the correct place if it is open.
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.
recomputeAriaContextCustomizes the label for this field to include "editable" if it applies.
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 slider when the field rerenders.
renderWarningIcon-
repositionForWindowResizeHandles repositioning the WidgetDiv used for input fields when the workspace is resized. Scrolls this field into view, then updates the position of the text input.
resizeEditor_Resize the editor to fit the text.
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.
setConstraintsSet the maximum, minimum and precision constraints on this field. Any of these properties may be undefined or NaN to be disabled. Setting precision (usually a power of 10) enforces a minimum step between values. That is, the user's value will rounded to the closest multiple of precision. The least significant digit place is inferred from the precision. Integers values can be enforces by choosing an integer precision.
setEditorValue_Set the HTML input value and the field's internal value. The difference between this and setValue is that this also updates the HTML input value whilst editing.
setEnabledSet whether this field's value can be changed using the editor when the source block is editable.
setMaxSets the maximum value this field can contain. Updates the value to reflect.
setMinSets the minimum value this field can contain. Updates the value to reflect.
setPrecisionSets the precision of this field's value, i.e. the number to which the value is rounded. Updates the field to reflect.
setSourceBlockAttach this field to a block.
setSpellcheckSet whether this field is spellchecked by the browser.
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.
showEditor_Show the inline free-text editor on top of the text along with the slider editor.
toXmlSerializes this field's value to XML. Should only be called by Blockly.Xml.
unbindInputEvents_Unbind handlers for user input and workspace size changes.
updateEditableAdd or remove the UI indicating if this field is editable or not.
updateSize_Updates the size of the field based on the text.
widgetCreate_Create the number input editor widget.
widgetDispose_Closes the editor, saves the results, and disposes of any events or DOM-references belonging to the editor.
fromJsonConstructs a FieldSlider from a JSON arg object.

Constructors​

Constructor​

new FieldSlider(
value?,
min?,
max?,
precision?,
validator?,
config?
): FieldSlider;

Defined in: plugins/field-slider/src/field_slider.ts:60

Class for an number slider field.

Parameters​

ParameterTypeDescription
value?string | numberThe initial value of the field. Should cast to a number. Defaults to 0.
min?string | numberMinimum value.
max?string | numberMaximum value.
precision?string | numberPrecision for value.
validator?FieldNumberValidatorA function that is called to validate changes to the field's value. Takes in a number & returns a validated number, or null to abort the change.
config?FieldNumberConfigA map of options used to configure the field. See the [field creation documentation]https://docs.blockly.com/guides/create-custom-blocks/fields/built-in-fields/number/#creation for a list of properties this parameter supports.

Returns​

FieldSlider

Overrides​

Blockly.FieldNumber.constructor

Properties​

ariaTypeName​

protected ariaTypeName: string | null;

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

Inherited from​

Blockly.FieldNumber.ariaTypeName


borderRect_​

protected borderRect_: SVGRectElement | null;

The rendered field's SVG border element.

Inherited from​

Blockly.FieldNumber.borderRect_


clickTarget_​

protected clickTarget_: Element | null;

The element the click handler is bound to.

Inherited from​

Blockly.FieldNumber.clickTarget_


constants_​

protected constants_: ConstantProvider | null;

Constants associated with the source block's renderer.

Inherited from​

Blockly.FieldNumber.constants_


DEFAULT_VALUE​

DEFAULT_VALUE: string | number | null;

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

Example: FieldImage.prototype.DEFAULT_VALUE = null;

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.EDITABLE


enabled_​

protected enabled_: boolean;

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

Inherited from​

Blockly.FieldNumber.enabled_


fieldGroup_​

protected fieldGroup_: SVGGElement | null;

The rendered field's SVG group element.

Inherited from​

Blockly.FieldNumber.fieldGroup_


fullBlockClickTarget_​

fullBlockClickTarget_: boolean;

Whether the field should consider the whole parent block to be its click target.

Inherited from​

Blockly.FieldNumber.fullBlockClickTarget_


htmlInput_​

protected htmlInput_: HTMLInputElement | null;

The HTML input element.

Inherited from​

Blockly.FieldNumber.htmlInput_


isBeingEdited_​

protected isBeingEdited_: boolean;

True if the field's value is currently being edited via the UI.

Inherited from​

Blockly.FieldNumber.isBeingEdited_


isDirty_​

protected isDirty_: boolean;

Does this block need to be re-rendered?

Inherited from​

Blockly.FieldNumber.isDirty_


isTextValid_​

protected isTextValid_: boolean;

True if the value currently displayed in the field's editory UI is valid.

Inherited from​

Blockly.FieldNumber.isTextValid_


max_​

protected max_: number;

The maximum value this number field can contain.

Inherited from​

Blockly.FieldNumber.max_


maxDisplayLength​

maxDisplayLength: number;

Maximum characters of text to display before adding an ellipsis.

Inherited from​

Blockly.FieldNumber.maxDisplayLength


min_​

protected min_: number;

The minimum value this number field can contain.

Inherited from​

Blockly.FieldNumber.min_


name?​

name?: string;

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

Inherited from​

Blockly.FieldNumber.name


precision_​

protected precision_: number;

The multiple to which this fields value is rounded.

Inherited from​

Blockly.FieldNumber.precision_


SERIALIZABLE​

SERIALIZABLE: boolean;

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

Inherited from​

Blockly.FieldNumber.SERIALIZABLE


sourceBlock_​

protected sourceBlock_: Block | null;

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

Inherited from​

Blockly.FieldNumber.sourceBlock_


spellcheck_​

protected spellcheck_: boolean;

Don't spellcheck numbers. Our validator does a better job.

Inherited from​

Blockly.FieldNumber.spellcheck_


textContent_​

protected textContent_: Text | null;

The rendered field's text content element.

Inherited from​

Blockly.FieldNumber.textContent_


textElement_​

protected textElement_: SVGTextElement | null;

The rendered field's SVG text element.

Inherited from​

Blockly.FieldNumber.textElement_


validator_​

protected validator_: FieldValidator<string | number> | null;

Validation function called when user edits an editable field.

Inherited from​

Blockly.FieldNumber.validator_


value_​

protected value_: string | number | null;

Inherited from​

Blockly.FieldNumber.value_


valueWhenEditorWasOpened_​

protected valueWhenEditorWasOpened_: string | number | null;

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.

Inherited from​

Blockly.FieldNumber.valueWhenEditorWasOpened_


visible_​

protected visible_: boolean;

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

Inherited from​

Blockly.FieldNumber.visible_


warningIcon​

protected warningIcon: SVGElement | null;

The warning icon to display on invalid input

Inherited from​

Blockly.FieldNumber.warningIcon


workspace_​

protected workspace_: WorkspaceSvg | null;

The workspace that this field belongs to.

Inherited from​

Blockly.FieldNumber.workspace_


BORDERRADIUS​

static BORDERRADIUS: number;

Pixel size of input border radius. Should match blocklyText's border-radius in CSS.

Inherited from​

Blockly.FieldNumber.BORDERRADIUS


NBSP​

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

Non-breaking space.

Inherited from​

Blockly.FieldNumber.NBSP


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​

Blockly.FieldNumber.SKIP_SETUP

Accessors​

size_​

Get Signature​

get protected size_(): Size;

Returns the size of this field, with a minimum width of 14.

Returns​

Size

Set Signature​

set protected size_(newValue): void;

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.

Parameters​
ParameterType
newValueSize
Returns​

void

Inherited from​

Blockly.FieldNumber.size_

Methods​

applyColour()​

applyColour(): void;

Updates text field to match the colour/style of the block.

Returns​

void

Inherited from​

Blockly.FieldNumber.applyColour


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​

Blockly.FieldNumber.bindEvents_


bindInputEvents_()​

protected bindInputEvents_(htmlInput): void;

Bind handlers for user input on the text input field's editor.

Parameters​

ParameterTypeDescription
htmlInputHTMLElementThe htmlInput to which event handlers will be bound.

Returns​

void

Inherited from​

Blockly.FieldNumber.bindInputEvents_


canBeFocused()​

canBeFocused(): boolean;

See IFocusableNode.canBeFocused.

Returns​

boolean

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.computeAriaLabel


configure_()​

protected configure_(config): void;

Configure the field based on the given map of options.

Parameters​

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

Returns​

void

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.createBorderRect_


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​

Blockly.FieldNumber.createTextElement_


createWarningIcon()​

protected createWarningIcon(): SVGElement | null;

Creates the DOM elements for the invalid input warning icon.

Returns​

SVGElement | null

Inherited from​

Blockly.FieldNumber.createWarningIcon


dispose()​

dispose(): void;

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

Returns​

void

Inherited from​

Blockly.FieldNumber.dispose


doClassValidation_()​

protected doClassValidation_(newValue?): number | null;

Ensure that the input value is a valid number (must fulfill the constraints placed on the field).

Parameters​

ParameterTypeDescription
newValue?anyThe input value.

Returns​

number | null

A valid number, or null if invalid.

Inherited from​

Blockly.FieldNumber.doClassValidation_


doValueInvalid_()​

protected doValueInvalid_(_invalidValue, fireChangeEvent?): void;

Called by setValue if the text input is not valid. If the field is currently being edited it reverts value of the field to the previous value while allowing the display text to be handled by the htmlInput_.

Parameters​

ParameterTypeDescription
_invalidValueanyThe input value that was determined to be invalid. This is not used by the text input because its display value is stored on the htmlInput_.
fireChangeEvent?booleanWhether to fire a change event if the value changes.

Returns​

void

Inherited from​

Blockly.FieldNumber.doValueInvalid_


doValueUpdate_()​

protected doValueUpdate_(newValue): void;

Called by setValue if the text input is valid. Updates the value of the field, and updates the text of the field if it is not currently being edited (i.e. handled by the htmlInput_).

Parameters​

ParameterTypeDescription
newValuestring | numberThe value to be saved. The default validator guarantees that this is a string.

Returns​

void

Inherited from​

Blockly.FieldNumber.doValueUpdate_


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​

Blockly.FieldNumber.forceRerender


fromXml()​

fromXml(fieldElement): void;

Sets the field's value based on the given XML element. Should only be called by Blockly.Xml.

Parameters​

ParameterTypeDescription
fieldElementElementThe element containing info about the field's state.

Returns​

void

Inherited from​

Blockly.FieldNumber.fromXml


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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.getAriaTypeName


getAriaValue()​

getAriaValue(): string | null;

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 | null

An ARIA representation of the field's text.

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.getClickTarget_


getConstants()​

getConstants(): ConstantProvider | null;

Get the renderer constant provider.

Returns​

ConstantProvider | null

The renderer constant provider.

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.getDisplayText_


getEditorText_()​

protected getEditorText_(value): string;

Transform the provided value into a text to show in the HTML input. Override this method if the field's HTML input representation is different than the field's value. This should be coupled with an override of getValueFromEditorText_.

Parameters​

ParameterTypeDescription
valueanyThe value stored in this field.

Returns​

string

The text to show on the HTML input.

Inherited from​

Blockly.FieldNumber.getEditorText_


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​

Blockly.FieldNumber.getFlipRtl


getFocusableElement()​

getFocusableElement(): HTMLElement | SVGElement;

See IFocusableNode.getFocusableElement.

Returns​

HTMLElement | SVGElement

Inherited from​

Blockly.FieldNumber.getFocusableElement


getFocusableTree()​

getFocusableTree(): IFocusableTree;

See IFocusableNode.getFocusableTree.

Returns​

IFocusableTree

Inherited from​

Blockly.FieldNumber.getFocusableTree


getMax()​

getMax(): number;

Returns the current maximum value this field can contain. Default is Infinity.

Returns​

number

The current maximum value this field can contain.

Inherited from​

Blockly.FieldNumber.getMax


getMin()​

getMin(): number;

Returns the current minimum value this field can contain. Default is -Infinity.

Returns​

number

The current minimum value this field can contain.

Inherited from​

Blockly.FieldNumber.getMin


getPrecision()​

getPrecision(): number;

Returns the current precision of this field. The precision being the number to which the field's value is rounded. A precision of 0 means that the value is not rounded.

Returns​

number

The number to which this field's value is rounded.

Inherited from​

Blockly.FieldNumber.getPrecision


getSize()​

getSize(): Size;

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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.getSvgRoot


getText()​

getText(): string;

Sealed

Get the text from this field. Override getText_ to provide a different behavior than simply casting the value to a string.

Returns​

string

Current text.

Inherited from​

Blockly.FieldNumber.getText


getText_()​

protected getText_(): string | null;

Use the getText_ developer hook to override the field's text representation. When we're currently editing, return the current HTML value instead. Otherwise, return null which tells the field to use the default behaviour (which is a string cast of the field's value).

Returns​

string | null

The HTML value if we're editing, otherwise null.

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.getTextElement


getTooltip()​

getTooltip(): string;

Returns the tooltip text for this field.

Returns​

string

The tooltip text for this field.

Inherited from​

Blockly.FieldNumber.getTooltip


getValidator()​

getValidator(): FieldValidator<string | number> | null;

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

Returns​

FieldValidator<string | number> | null

Validation function, or null.

Inherited from​

Blockly.FieldNumber.getValidator


getValue()​

getValue(): string | number | null;

Get the current value of the field.

Returns​

string | number | null

Current value.

Inherited from​

Blockly.FieldNumber.getValue


getValueFromEditorText_()​

protected getValueFromEditorText_(text): any;

Transform the text received from the HTML input into a value to store in this field. Override this method if the field's HTML input representation is different than the field's value. This should be coupled with an override of getEditorText_.

Parameters​

ParameterTypeDescription
textstringText received from the HTML input.

Returns​

any

The value to store.

Inherited from​

Blockly.FieldNumber.getValueFromEditorText_


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​

Blockly.FieldNumber.initModel


initView()​

initView(): void;

Initialize the field's DOM.

Returns​

void

Inherited from​

Blockly.FieldNumber.initView


isClickable()​

isClickable(): boolean;

Check whether this field defines the showEditor_ function.

Returns​

boolean

Whether this field is clickable.

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.isEnabled


isFullBlockField()​

isFullBlockField(): boolean;

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

This is typically only done for certain kinds of fields and in certain renderers. You should only override this if you're sure your field will render correctly in zelos and other renderers that support full-block fields.

Blocks that contain only a single field that is a full-block-field have a special appearance in some renderers and their behavior is unique, because we pretend that the field is a whole block in some cases. This is hacky and you should use caution when attempting to do anything with this method.

Returns​

boolean

Inherited from​

Blockly.FieldNumber.isFullBlockField


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​

Blockly.FieldNumber.isSerializable


isVisible()​

isVisible(): boolean;

Gets whether this editable field is visible or not.

Returns​

boolean

True if visible.

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.loadLegacyState


loadState()​

loadState(state): void;

Sets the field's state based on the given state value. Should only be called by the serialization system.

Parameters​

ParameterTypeDescription
stateanyThe state we want to apply to the field.

Returns​

void

Inherited from​

Blockly.FieldNumber.loadState


onFinishEditing_()​

onFinishEditing_(_value): void;

A callback triggered when the user is done editing the field via the UI.

Parameters​

ParameterTypeDescription
_valueanyThe new value of the field.

Returns​

void

Inherited from​

Blockly.FieldNumber.onFinishEditing_


onHtmlInputKeyDown_()​

protected onHtmlInputKeyDown_(e): void;

Handle key down to the editor.

Parameters​

ParameterTypeDescription
eKeyboardEventKeyboard event.

Returns​

void

Inherited from​

Blockly.FieldNumber.onHtmlInputKeyDown_


onLocationChange()​

onLocationChange(): void;

Notifies the field that it has changed locations. Moves the widget div to be in the correct place if it is open.

Returns​

void

Inherited from​

Blockly.FieldNumber.onLocationChange


onMouseDown_()​

protected onMouseDown_(e): void;

Handle a pointerdown event on a field.

Parameters​

ParameterTypeDescription
ePointerEventPointer down event.

Returns​

void

Inherited from​

Blockly.FieldNumber.onMouseDown_


onNodeBlur()​

onNodeBlur(): void;

See IFocusableNode.onNodeBlur.

Returns​

void

Inherited from​

Blockly.FieldNumber.onNodeBlur


onNodeFocus()​

onNodeFocus(): void;

See IFocusableNode.onNodeFocus.

Returns​

void

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.onShortcut


performAction()​

performAction(): void;

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

Returns​

void

Inherited from​

Blockly.FieldNumber.performAction


positionBorderRect_()​

protected positionBorderRect_(): void;

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

Returns​

void

Inherited from​

Blockly.FieldNumber.positionBorderRect_


positionTextElement_()​

protected positionTextElement_(xMargin, contentWidth): void;

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

Parameters​

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

Returns​

void

Inherited from​

Blockly.FieldNumber.positionTextElement_


recomputeAriaContext()​

recomputeAriaContext(): boolean;

Customizes the label for this field to include "editable" if it applies.

Returns​

boolean

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.referencesVariables


refreshVariableName()​

refreshVariableName(): void;

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

Returns​

void

Inherited from​

Blockly.FieldNumber.refreshVariableName


render_()​

protected render_(): void;

Defined in: plugins/field-slider/src/field_slider.ts:140

Updates the slider when the field rerenders.

Returns​

void

Overrides​

Blockly.FieldNumber.render_


renderWarningIcon()​

protected renderWarningIcon(rtl, isValid): void;

Parameters​

ParameterType
rtlboolean
isValidboolean

Returns​

void

Inherited from​

Blockly.FieldNumber.renderWarningIcon


repositionForWindowResize()​

repositionForWindowResize(): boolean;

Handles repositioning the WidgetDiv used for input fields when the workspace is resized. Scrolls this field into view, then updates the position of the text input.

Returns​

boolean

True for rendered workspaces, as we never want to hide the widget div.

Inherited from​

Blockly.FieldNumber.repositionForWindowResize


resizeEditor_()​

protected resizeEditor_(): void;

Resize the editor to fit the text.

Returns​

void

Inherited from​

Blockly.FieldNumber.resizeEditor_


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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.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​

Blockly.FieldNumber.setAriaTypeName


setConstraints()​

setConstraints(
min,
max,
precision
): void;

Set the maximum, minimum and precision constraints on this field. Any of these properties may be undefined or NaN to be disabled. Setting precision (usually a power of 10) enforces a minimum step between values. That is, the user's value will rounded to the closest multiple of precision. The least significant digit place is inferred from the precision. Integers values can be enforces by choosing an integer precision.

Parameters​

ParameterTypeDescription
minstring | number | null | undefinedMinimum value.
maxstring | number | null | undefinedMaximum value.
precisionstring | number | null | undefinedPrecision for value.

Returns​

void

Inherited from​

Blockly.FieldNumber.setConstraints


setEditorValue_()​

protected setEditorValue_(newValue, fireChangeEvent?): void;

Set the HTML input value and the field's internal value. The difference between this and setValue is that this also updates the HTML input value whilst editing.

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​

Blockly.FieldNumber.setEditorValue_


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​

Blockly.FieldNumber.setEnabled


setMax()​

setMax(max): void;

Sets the maximum value this field can contain. Updates the value to reflect.

Parameters​

ParameterTypeDescription
maxstring | number | null | undefinedMaximum value.

Returns​

void

Inherited from​

Blockly.FieldNumber.setMax


setMin()​

setMin(min): void;

Sets the minimum value this field can contain. Updates the value to reflect.

Parameters​

ParameterTypeDescription
minstring | number | null | undefinedMinimum value.

Returns​

void

Inherited from​

Blockly.FieldNumber.setMin


setPrecision()​

setPrecision(precision): void;

Sets the precision of this field's value, i.e. the number to which the value is rounded. Updates the field to reflect.

Parameters​

ParameterTypeDescription
precisionstring | number | null | undefinedThe number to which the field's value is rounded.

Returns​

void

Inherited from​

Blockly.FieldNumber.setPrecision


setSourceBlock()​

setSourceBlock(block): void;

Attach this field to a block.

Parameters​

ParameterTypeDescription
blockBlockThe block containing this field.

Returns​

void

Inherited from​

Blockly.FieldNumber.setSourceBlock


setSpellcheck()​

setSpellcheck(check): void;

Set whether this field is spellchecked by the browser.

Parameters​

ParameterTypeDescription
checkbooleanTrue if checked.

Returns​

void

Inherited from​

Blockly.FieldNumber.setSpellcheck


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​

Blockly.FieldNumber.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 | number>The validator function or null to clear a previous validator.

Returns​

void

Inherited from​

Blockly.FieldNumber.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​

Blockly.FieldNumber.setValue


showEditor_()​

protected showEditor_(e?, quietInput?): void;

Defined in: plugins/field-slider/src/field_slider.ts:102

Show the inline free-text editor on top of the text along with the slider editor.

Parameters​

ParameterTypeDescription
e?EventOptional mouse event that triggered the field to open, or undefined if triggered programmatically.
quietInput?booleanQuiet input (prevent focusing on the editor).

Returns​

void

Overrides​

Blockly.FieldNumber.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​

Blockly.FieldNumber.toXml


unbindInputEvents_()​

protected unbindInputEvents_(): void;

Unbind handlers for user input and workspace size changes.

Returns​

void

Inherited from​

Blockly.FieldNumber.unbindInputEvents_


updateEditable()​

updateEditable(): void;

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

Returns​

void

Inherited from​

Blockly.FieldNumber.updateEditable


updateSize_()​

protected updateSize_(margin?): void;

Updates the size of the field based on the text.

Parameters​

ParameterTypeDescription
margin?numbermargin to use when positioning the text element.

Returns​

void

Inherited from​

Blockly.FieldNumber.updateSize_


widgetCreate_()​

protected widgetCreate_(): HTMLInputElement;

Create the number input editor widget.

Returns​

HTMLInputElement

The newly created number input editor.

Inherited from​

Blockly.FieldNumber.widgetCreate_


widgetDispose_()​

protected widgetDispose_(): void;

Closes the editor, saves the results, and disposes of any events or DOM-references belonging to the editor.

Returns​

void

Inherited from​

Blockly.FieldNumber.widgetDispose_


fromJson()​

static fromJson(options): FieldSlider;

Defined in: plugins/field-slider/src/field_slider.ts:80

Constructs a FieldSlider from a JSON arg object.

Parameters​

ParameterTypeDescription
optionsFieldSliderOptionsA JSON object with options (value, min, max, precision).

Returns​

FieldSlider

The new field instance.

Package​

Nocollapse​

Overrides​

Blockly.FieldNumber.fromJson