Class: FieldBitmap
Defined in: plugins/field-bitmap/src/field-bitmap.ts:25
Field for inputting a small bitmap image. Includes a grid of clickable pixels that's exported as a bitmap.
Extends
Field<number[][]>
Properties index
| Property | Description |
|---|---|
| ariaTypeName | The ARIA-friendly label representation of this field's type. |
| borderRect_ | The rendered field's SVG border element. |
| buttonOptions | - |
| clickTarget_ | The element the click handler is bound to. |
| constants_ | Constants associated with the source block's renderer. |
| DEFAULT_VALUE | To overwrite the default value which is set in Field, directly update the prototype. |
| EDITABLE | Editable 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. |
| fieldHeight | - |
| isDirty_ | Does this block need to be re-rendered? |
| maxDisplayLength | Maximum characters of text to display before adding an ellipsis. |
| name | Name of field. Unique within each block. Static labels are usually unnamed. |
| pixelColours | - |
| pixelSize | - |
| SERIALIZABLE | Serializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable. This is not the case by default so that SERIALIZABLE is backwards compatible. |
| 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_ | - |
| visible_ | Is the field visible, or hidden due to the block being collapsed? |
| NBSP | Non-breaking space. |
| 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. |
Methods index
| Method | Description |
|---|---|
| applyColour | Updates the 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. |
| canBeFocused | See IFocusableNode.canBeFocused. |
| computeAriaLabel | Computes a descriptive ARIA label to represent this field with configurable verbosity. |
| configure_ | Process the configuration map passed to the field. |
| 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. |
| dispose | Dispose of all DOM objects and events belonging to this editable field. |
| doClassValidation_ | Validates that a new value meets the requirements for a valid bitmap array. |
| doValueInvalid_ | Used to notify the field an invalid value was input. Can be overridden by subclasses, see FieldTextInput. No-op by default. |
| doValueUpdate_ | Called when a new value has been validated and is about to be set. |
| dropdownCreate | Creates the bitmap editor and add event listeners. |
| dropdownDispose | Disposes of events belonging to the bitmap editor. |
| fireIntermediateChangeEvent | - |
| forceRerender | 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. |
| fromXml | Sets 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. |
| getAriaTypeName | Gets an ARIA-friendly label representation of this field's type. |
| getAriaValue | Gets an ARIA-friendly label representation of this field's value. |
| getBorderRect | Gets 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. |
| getConstants | Get 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. |
| getFlipRtl | Returns whether or not we should flip the field in RTL. |
| getFocusableElement | See IFocusableNode.getFocusableElement. |
| getFocusableTree | See IFocusableNode.getFocusableTree. |
| getImageHeight | Returns the height of the image in pixels. |
| getImageWidth | Returns the width of the image in pixels. |
| getScaledBBox | Gets the rectangle built out of dimensions matching SVG's |
| getSize | Returns the height and width of the field. |
| getSourceBlock | Get the block this field is attached to. |
| getSvgRoot | Gets the group element for this editable field. Used for measuring the size and for positioning. |
| getText | Get the text from this field. Override getText_ to provide a different behavior than simply casting the value to a string. |
| getText_ | A developer hook to override the returned text of this field. Override if the text representation of the value of this field is not just a string cast of its value. Return null to resort to a string cast. |
| getTextContent | Gets the text content. |
| getTextElement | Gets the text element. |
| getTooltip | Returns the tooltip text for this field. |
| getValidator | Gets the validation function for editable fields, or null if not set. |
| getValue | Get the current value of the field. |
| initModel | Initializes the model of the field after it has been installed on a block. No-op by default. |
| initView | Initializes the on-block display. |
| isClickable | Check whether this field defines the showEditor_ function. |
| isClickableInFlyout | 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. |
| isCurrentlyEditable | 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. |
| isEnabled | Check whether this field's value can be changed using the editor when the source block is editable. |
| isFullBlockField | Defines whether this field should take up the full block or not. |
| isSerializable | Check whether this field should be serialized by the XML renderer. Handles the logic for backwards compatibility and incongruous states. |
| isVisible | Gets whether this editable field is visible or not. |
| loadLegacyState | 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. |
| loadState | Sets the field's state based on the given state value. Should only be called by the serialization system. |
| onLocationChange | Notifies the field that it has changed locations. |
| onMouseDown_ | Handle a pointerdown event on a field. |
| onNodeBlur | See IFocusableNode.onNodeBlur. |
| onNodeFocus | See IFocusableNode.onNodeFocus. |
| onShortcut | Handles the given keyboard shortcut. |
| performAction | Handles 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. |
| recomputeAriaContext | Updates the ARIA roles and label for this field. |
| referencesVariables | 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. |
| refreshVariableName | Refresh the variable name referenced by this field if this field references variables. |
| render_ | Updates the block display and editor dropdown when the field re-renders. |
| repositionForWindowResize | 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. |
| saveLegacyState | 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. |
| saveState | Saves this fields value as something which can be serialized to JSON. Should only be called by the serialization system. |
| setAriaTypeName | Sets the ARIA-friendly label representation of this field's type. |
| setEnabled | Set whether this field's value can be changed using the editor when the source block is editable. |
| setSourceBlock | Attach this field to a block. |
| setTooltip | Sets the tooltip for this field. |
| setValidator | Sets a new validation function for editable fields, or clears a previously set validator. |
| setValue | Used to change the value of the field. Handles validation and events. Subclasses should override doClassValidation_ and doValueUpdate_ rather than this method. |
| showEditor_ | Show the bitmap editor dialog. |
| toXml | Serializes this field's value to XML. Should only be called by Blockly.Xml. |
| updateEditable | Determines whether the field is editable. |
| updateSize_ | Updates the size of the block based on the size of the underlying image. |
| fromJson | Constructs a FieldBitmap from a JSON arg object. |
Constructors
Constructor
new FieldBitmap(
value,
validator?,
config?
): FieldBitmap;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:57
Constructor for the bitmap field.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | number[][] | typeof SKIP_SETUP | 2D rectangular array of 1s and 0s. |
validator? | FieldValidator<number[][]> | A function that is called to validate. |
config? | FieldBitmapFromJsonConfig | Config A map of options used to configure the field. |
Returns
FieldBitmap
Overrides
Blockly.Field<number[][]>.constructor
Properties
ariaTypeName
protected ariaTypeName: string;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:48
The ARIA-friendly label representation of this field's type.
Overrides
Blockly.Field.ariaTypeName
borderRect_
protected borderRect_: SVGRectElement | null;
The rendered field's SVG border element.
Inherited from
Blockly.Field.borderRect_
buttonOptions
buttonOptions: Buttons;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:43
clickTarget_
protected clickTarget_: Element | null;
The element the click handler is bound to.
Inherited from
Blockly.Field.clickTarget_
constants_
protected constants_: ConstantProvider | null;
Constants associated with the source block's renderer.
Inherited from
Blockly.Field.constants_
DEFAULT_VALUE
DEFAULT_VALUE: 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.Field.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.Field.EDITABLE
enabled_
protected enabled_: boolean;
Can the field value be changed using the editor on an editable block?
Inherited from
Blockly.Field.enabled_
fieldGroup_
protected fieldGroup_: SVGGElement | null;
The rendered field's SVG group element.
Inherited from
Blockly.Field.fieldGroup_
fieldHeight?
fieldHeight?: number;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:46
isDirty_
protected isDirty_: boolean;
Does this block need to be re-rendered?
Inherited from
Blockly.Field.isDirty_
maxDisplayLength
maxDisplayLength: number;
Maximum characters of text to display before adding an ellipsis.
Inherited from
Blockly.Field.maxDisplayLength
name?
name?: string;
Name of field. Unique within each block. Static labels are usually unnamed.
Inherited from
Blockly.Field.name
pixelColours
pixelColours: object;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:45
empty
empty: string;
filled
filled: string;
pixelSize
pixelSize: number;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:44
SERIALIZABLE
SERIALIZABLE: boolean;
Serializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable. This is not the case by default so that SERIALIZABLE is backwards compatible.
Inherited from
Blockly.Field.SERIALIZABLE
sourceBlock_
protected sourceBlock_: Block | null;
Block this field is attached to. Starts as null, then set in init.
Inherited from
Blockly.Field.sourceBlock_
textContent_
protected textContent_: Text | null;
The rendered field's text content element.
Inherited from
Blockly.Field.textContent_
textElement_
protected textElement_: SVGTextElement | null;
The rendered field's SVG text element.
Inherited from
Blockly.Field.textElement_
validator_
protected validator_: FieldValidator<number[][]> | null;
Validation function called when user edits an editable field.
Inherited from
Blockly.Field.validator_
value_
protected value_: number[][] | null;
Inherited from
Blockly.Field.value_
visible_
protected visible_: boolean;
Is the field visible, or hidden due to the block being collapsed?
Inherited from
Blockly.Field.visible_
NBSP
readonly static NBSP: " " = "\u00A0";
Non-breaking space.
Inherited from
Blockly.Field.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.Field.SKIP_SETUP
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
| Parameter | Type |
|---|---|
newValue | Size |
Returns
void
Inherited from
Blockly.Field.size_
Methods
applyColour()
applyColour(): void;
Updates the field to match the colour/style of the block.
Non-abstract sub-classes may wish to implement this if the colour of the field depends on the colour of the block. It will automatically be called at relevant times, such as when the parent block or renderer changes.
See the field documentation for more information, or FieldDropdown for an example.
Returns
void
Inherited from
Blockly.Field.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.Field.bindEvents_
canBeFocused()
canBeFocused(): boolean;
See IFocusableNode.canBeFocused.
Returns
boolean
Inherited from
Blockly.Field.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
| Parameter | Type | Description |
|---|---|---|
includeTypeInfo? | boolean | Whether to include the field's type information in the returned label, if available. |
Returns
string
Inherited from
Blockly.Field.computeAriaLabel
configure_()
protected configure_(config): void;
Process the configuration map passed to the field.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | FieldConfig | A map of options used to configure the field. See the individual field's documentation for a list of properties this parameter supports. |
Returns
void
Inherited from
Blockly.Field.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.Field.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.Field.createTextElement_
dispose()
dispose(): void;
Dispose of all DOM objects and events belonging to this editable field.
Returns
void
Inherited from
Blockly.Field.dispose
doClassValidation_()
Call Signature
protected doClassValidation_(newValue): number[][] | null | undefined;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:147
Validates that a new value meets the requirements for a valid bitmap array.
Parameters
| Parameter | Type | Description |
|---|---|---|
newValue | number[][] | The new value to be tested. |
Returns
number[][] | null | undefined
The new value if it's valid, or null.
Overrides
Blockly.Field.doClassValidation_
Call Signature
protected doClassValidation_(newValue?): number[][] | null;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:151
Validates that a new value meets the requirements for a valid bitmap array.
Parameters
| Parameter | Type | Description |
|---|---|---|
newValue? | number[][] | The new value to be tested. |
Returns
number[][] | null
The new value if it's valid, or null.
Overrides
Blockly.Field.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
| Parameter | Type | Description |
|---|---|---|
_invalidValue | any | The input value that was determined to be invalid. |
_fireChangeEvent? | boolean | Whether to fire a change event if the value changes. |
Returns
void
Inherited from
Blockly.Field.doValueInvalid_
doValueUpdate_()
protected doValueUpdate_(newValue): void;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:200
Called when a new value has been validated and is about to be set.
Parameters
| Parameter | Type | Description |
|---|---|---|
newValue | number[][] | The value that's about to be set. |
Returns
void
Overrides
Blockly.Field.doValueUpdate_
dropdownCreate()
protected dropdownCreate(): HTMLElement;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:324
Creates the bitmap editor and add event listeners.
Returns
HTMLElement
The newly created dropdown menu.
dropdownDispose()
protected dropdownDispose(): void;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:692
Disposes of events belonging to the bitmap editor.
Returns
void
fireIntermediateChangeEvent()
protected fireIntermediateChangeEvent(newValue): void;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:930
Parameters
| Parameter | Type |
|---|---|
newValue | number[][] |
Returns
void
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.Field.forceRerender
fromXml()
fromXml(fieldElement): void;
Sets the field's value based on the given XML element. Should only be called by Blockly.Xml.
Parameters
| Parameter | Type | Description |
|---|---|---|
fieldElement | Element | The element containing info about the field's state. |
Returns
void
Inherited from
Blockly.Field.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.Field.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 null if it is unspecified.
Inherited from
Blockly.Field.getAriaTypeName
getAriaValue()
getAriaValue(): string | null;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:260
Gets an ARIA-friendly label representation of this field's value.
Note that implementations should generally always override this value to ensure a non-null value is returned. The default implementation relies on 'getText' which may return an empty string. A null return value from this function will prompt ARIA label generation to skip the field's value entirely when there may be a better contextual placeholder to use isstead.
For example, to avoid hiding an empty text input field from screen reader, implementations should ensure that if the text is an empty string, this function would return an appropriate, localized value such as "empty text".
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, or null if no text is currently defined or known for the field.
Overrides
Blockly.Field.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.Field.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.Field.getClickTarget_
getConstants()
getConstants(): ConstantProvider | null;
Get the renderer constant provider.
Returns
ConstantProvider | null
The renderer constant provider.
Inherited from
Blockly.Field.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.Field.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
Blockly.Field.getFlipRtl
getFocusableElement()
getFocusableElement(): HTMLElement | SVGElement;
See IFocusableNode.getFocusableElement.
Returns
HTMLElement | SVGElement
Inherited from
Blockly.Field.getFocusableElement
getFocusableTree()
getFocusableTree(): IFocusableTree;
See IFocusableNode.getFocusableTree.
Returns
IFocusableTree
Inherited from
Blockly.Field.getFocusableTree
getImageHeight()
getImageHeight(): number;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:116
Returns the height of the image in pixels.
Returns
number
The height in pixels.
getImageWidth()
getImageWidth(): number;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:107
Returns the width of the image in pixels.
Returns
number
The width in pixels.
getScaledBBox()
getScaledBBox(): Rect;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:306
Gets the rectangle built out of dimensions matching SVG's
Returns
Rect
The newly created rectangle of same size as the SVG element.
Overrides
Blockly.Field.getScaledBBox
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.Field.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.Field.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.Field.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.Field.getText
getText_()
protected getText_(): string | null;
A developer hook to override the returned text of this field. Override if the text representation of the value of this field is not just a string cast of its value. Return null to resort to a string cast.
Returns
string | null
Current text or null.
Inherited from
Blockly.Field.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.Field.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.Field.getTextElement
getTooltip()
getTooltip(): string;
Returns the tooltip text for this field.
Returns
string
The tooltip text for this field.
Inherited from
Blockly.Field.getTooltip
getValidator()
getValidator(): FieldValidator<number[][]> | null;
Gets the validation function for editable fields, or null if not set.
Returns
FieldValidator<number[][]> | null
Validation function, or null.
Inherited from
Blockly.Field.getValidator
getValue()
getValue(): number[][] | null;
Get the current value of the field.
Returns
number[][] | null
Current value.
Inherited from
Blockly.Field.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
Blockly.Field.initModel
initView()
initView(): void;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:618
Initializes the on-block display.
Returns
void
Overrides
Blockly.Field.initView
isClickable()
isClickable(): boolean;
Check whether this field defines the showEditor_ function.
Returns
boolean
Whether this field is clickable.
Inherited from
Blockly.Field.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
| Parameter | Type | Description |
|---|---|---|
autoClosingFlyout | boolean | true 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.Field.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.Field.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.Field.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.Field.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.Field.isSerializable
isVisible()
isVisible(): boolean;
Gets whether this editable field is visible or not.
Returns
boolean
True if visible.
Inherited from
Blockly.Field.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
| Parameter | Type | Description |
|---|---|---|
callingClass | FieldProto | The class calling this method. Used to see if this has overridden any relevant hooks. |
state | any | The state to apply to the field. |
Returns
boolean
Whether the state was applied or not.
Inherited from
Blockly.Field.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
| Parameter | Type | Description |
|---|---|---|
state | any | The state we want to apply to the field. |
Returns
void
Inherited from
Blockly.Field.loadState
onLocationChange()
onLocationChange(_): void;
Notifies the field that it has changed locations.
Parameters
| Parameter | Type | Description |
|---|---|---|
_ | Coordinate | The location of this field's block's top-start corner in workspace coordinates. |
Returns
void
Inherited from
Blockly.Field.onLocationChange
onMouseDown_()
protected onMouseDown_(e): void;
Handle a pointerdown event on a field.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | PointerEvent | Pointer down event. |
Returns
void
Inherited from
Blockly.Field.onMouseDown_
onNodeBlur()
onNodeBlur(): void;
See IFocusableNode.onNodeBlur.
Returns
void
Inherited from
Blockly.Field.onNodeBlur
onNodeFocus()
onNodeFocus(): void;
See IFocusableNode.onNodeFocus.
Returns
void
Inherited from
Blockly.Field.onNodeFocus
onShortcut()
onShortcut(_shortcut): boolean;
Handles the given keyboard shortcut.
Parameters
| Parameter | Type | Description |
|---|---|---|
_shortcut | KeyboardShortcut | The shortcut to be handled. |
Returns
boolean
True if the shortcut has been handled, false otherwise.
Inherited from
Blockly.Field.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.Field.performAction
positionBorderRect_()
protected positionBorderRect_(): void;
Position a field's border rect after a size change.
Returns
void
Inherited from
Blockly.Field.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
| Parameter | Type | Description |
|---|---|---|
xOffset | number | x offset to use when positioning the text element. |
contentWidth | number | The content width. |
Returns
void
Inherited from
Blockly.Field.positionTextElement_
recomputeAriaContext()
recomputeAriaContext(): boolean;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:123
Updates the ARIA roles and label for this field.
Returns
boolean
Overrides
Blockly.Field.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.Field.referencesVariables
refreshVariableName()
refreshVariableName(): void;
Refresh the variable name referenced by this field if this field references variables.
Returns
void
Inherited from
Blockly.Field.refreshVariableName
render_()
protected render_(): void;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:237
Updates the block display and editor dropdown when the field re-renders.
Returns
void
Overrides
Blockly.Field.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
Blockly.Field.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
| Parameter | Type | Description |
|---|---|---|
callingClass | FieldProto | The 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.Field.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
| Parameter | Type | Description |
|---|---|---|
_doFullSerialization? | boolean | If 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.Field.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
| Parameter | Type | Description |
|---|---|---|
ariaTypeName | string | An ARIA representation of the field's type. |
Returns
void
Inherited from
Blockly.Field.setAriaTypeName
setEnabled()
setEnabled(enabled): void;
Set whether this field's value can be changed using the editor when the source block is editable.
Parameters
| Parameter | Type | Description |
|---|---|---|
enabled | boolean | True if enabled. |
Returns
void
Inherited from
Blockly.Field.setEnabled
setSourceBlock()
setSourceBlock(block): void;
Attach this field to a block.
Parameters
| Parameter | Type | Description |
|---|---|---|
block | Block | The block containing this field. |
Returns
void
Inherited from
Blockly.Field.setSourceBlock
setTooltip()
setTooltip(newTip): void;
Sets the tooltip for this field.
Parameters
| Parameter | Type | Description |
|---|---|---|
newTip | TipInfo | null | The 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.Field.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
| Parameter | Type | Description |
|---|---|---|
handler | FieldValidator<number[][]> | The validator function or null to clear a previous validator. |
Returns
void
Inherited from
Blockly.Field.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
| Parameter | Type | Description |
|---|---|---|
newValue | any | New value. |
fireChangeEvent? | boolean | Whether 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.Field.setValue
showEditor_()
protected showEditor_(e?): void;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:222
Show the bitmap editor dialog.
Parameters
| Parameter | Type | Description |
|---|---|---|
e? | Event | Optional mouse event that triggered the field to open, or undefined if triggered programmatically. |
Returns
void
Overrides
Blockly.Field.showEditor_
toXml()
toXml(fieldElement): Element;
Serializes this field's value to XML. Should only be called by Blockly.Xml.
Parameters
| Parameter | Type | Description |
|---|---|---|
fieldElement | Element | The element to populate with info about the field's state. |
Returns
Element
The element containing info about the field's state.
Inherited from
Blockly.Field.toXml
updateEditable()
updateEditable(): void;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:288
Determines whether the field is editable.
Returns
void
True since it is always editable.
Overrides
Blockly.Field.updateEditable
updateSize_()
protected updateSize_(): void;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:657
Updates the size of the block based on the size of the underlying image.
Returns
void
Overrides
Blockly.Field.updateSize_
fromJson()
static fromJson(options): FieldBitmap;
Defined in: plugins/field-bitmap/src/field-bitmap.ts:93
Constructs a FieldBitmap from a JSON arg object.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | FieldBitmapFromJsonConfig | A JSON object with options. |
Returns
FieldBitmap
The new field instance.
Overrides
Blockly.Field.fromJson