Class: BlockSvg
Defined in: packages/blockly/core/block_svg.ts:78
Class for a block's SVG representation. Not normally called directly, workspace.newBlock() is preferred.
Extends
Implements
Properties index
| Property | Description |
|---|---|
| onchange | An optional callback method to use whenever the block's parent workspace changes. This is usually only called from the constructor, the block type initializer function, or an extension initializer function. |
| COLLAPSED_INPUT_NAME | The language-neutral ID given to the collapsed input. |
| COLLAPSED_FIELD_NAME | The language-neutral ID given to the collapsed field. |
| data | Optional text data that round-trips between blocks and XML. Has no effect. May be used by 3rd parties for meta information. |
| colour_ | Colour of the block in '#RRGGBB' format. |
| styleName_ | Name of the block style. |
| init | An optional method called during initialization. |
| destroy | An optional method called during disposal. |
| mutationToDom | An optional serialization method for defining how to serialize the mutation state to XML. This must be coupled with defining domToMutation. |
| domToMutation | An optional deserialization method for defining how to deserialize the mutation state from XML. This must be coupled with defining mutationToDom. |
| saveExtraState | An optional serialization method for defining how to serialize the block's extra state (eg mutation state) to something JSON compatible. This must be coupled with defining loadExtraState. |
| loadExtraState | An optional serialization method for defining how to deserialize the block's extra state (eg mutation state) from something JSON compatible. This must be coupled with defining saveExtraState. |
| suppressPrefixSuffix | An optional property for suppressing adding STATEMENT_PREFIX and STATEMENT_SUFFIX to generated code. |
| getDeveloperVariables | An optional method for declaring developer variables, to be used by generators. Developer variables are never shown to the user, but are declared as global variables in the generated code. |
| compose | An optional method that reconfigures the block based on the contents of the mutator dialog. |
| id | - |
| inputList | - |
| inputsInline | - |
| icons | - |
| tooltip | - |
| contextMenu | - |
| parentBlock_ | - |
| childBlocks_ | - |
| collapsed_ | - |
| outputShape_ | - |
| disposing | Is the current block currently in the process of being disposed? |
| xy | - |
| isInFlyout | - |
| isInMutator | - |
| RTL | - |
| isInsertionMarker_ | True if this block is an insertion marker. |
| hat | Name of the type of hat. |
| helpUrl | String for block help, or function that returns a URL. Null for no help. |
| type | - |
| inputsInlineDefault | - |
| INLINE | Constant for identifying rows that are to be rendered inline. Don't collide with Blockly.inputTypes. |
| COLLAPSED_WARNING_ID | ID to give the "collapsed warnings" warning. Allows us to remove the "collapsed warnings" warning without removing any warnings that belong to the block. |
| decompose | An optional function that populates the mutator flyout with blocks representing this block's configuration. |
| saveConnections | An optional method which saves a record of blocks connected to this block so they can be later restored after this block is recoomposed (reconfigured). Typically records the connected blocks on properties on blocks in the mutator flyout, so that rearranging those component blocks will automatically rearrange the corresponding connected blocks on this block after this block is recomposed. |
| customContextMenu | - |
| height | Height of this block, not including any statement blocks above or below. Height is in workspace units. |
| width | Width of this block, including any connected value blocks. Width is in workspace units. |
| mutator | Block's mutator icon (if any). |
| style | - |
| rendered | Is this block a BlockSVG? |
| workspace | - |
| outputConnection | - |
| nextConnection | - |
| previousConnection | - |
Methods index
| Method | Description |
|---|---|
| doInit_ | Calls the init() function and handles associated event firing, etc. |
| initModel | Call initModel on all fields on the block. May be called more than once. Either initModel or initSvg must be called after creating a block and before the first interaction with it. Interactions include UI actions (e.g. clicking and dragging) and firing events (e.g. create, delete, and change). |
| unplug | Unplug this block from its superior block. If this block is a statement, optionally reconnect the block underneath with the block on top. |
| getParent | Return the parent block or null if this block is at the top level. The parent block is either the block connected to the previous connection (for a statement block) or the block connected to the output connection (for a value block). |
| getInputWithBlock | Return the input that connects to the specified block. |
| getSurroundParent | Return the parent block that surrounds the current block, or null if this block has no surrounding block. A parent block might just be the previous statement, whereas the surrounding block is an if statement, while loop, etc. |
| getRootBlock | Return the top-most block in this block's tree. This will return itself if this block is at the top level. |
| getDescendants | Find all the blocks that are directly or indirectly nested inside this one. Includes this block in the list. Includes value and statement inputs, as well as any following statements. Excludes any connection on an output tab or any preceding statements. Blocks are optionally sorted by position; top to bottom. |
| isDeletable | Get whether this block is deletable or not. |
| isOwnDeletable | Return whether this block's own deletable property is true or false. |
| isDuplicatable | Get whether is block is duplicatable or not. If duplicating this block and descendants will put this block over the workspace's capacity this block is not duplicatable. If duplicating this block and descendants will put any type over their maxInstances this block is not duplicatable. |
| isShadow | Get whether this block is a shadow block or not. |
| isInsertionMarker | Get whether this block is an insertion marker block or not. |
| isOwnEditable | Return whether this block's own editable property is true or false. |
| isDisposed | Returns if this block has been disposed of / deleted. |
| setHelpUrl | Set the URL of this block's help page. |
| setTooltip | Sets the tooltip for this block. |
| getTooltip | Returns the tooltip text for this block. |
| getStyleName | Get the name of the block style. |
| getHue | Get the HSV hue value of a block. Null if hue not set. |
| setOnChange | Sets a callback function to use whenever the block's parent workspace changes, replacing any prior onchange handler. This is usually only called from the constructor, the block type initializer function, or an extension initializer function. |
| getField | Returns the named field from a block. |
| getFields | Returns a generator that provides every field on the block. |
| getVarModels | Return all variables referenced by this block. |
| renameVarById | Notification that a variable is renaming. If the ID matches one of this block's variables, rename it. |
| getFieldValue | Returns the language-neutral value of the given field. |
| setFieldValue | Sets the value of the given field for this block. |
| getInputsInline | Get whether value inputs are arranged horizontally or vertically. |
| setOutputShape | Set the block's output shape. |
| getOutputShape | Get the block's output shape. |
| isEnabled | Get whether this block is enabled or not. A block is considered enabled if there aren't any reasons why it would be disabled. A block may still be disabled for other reasons even if the user attempts to manually enable it, such as when the block is in an invalid location. |
| getInheritedDisabled | Get whether the block is disabled or not due to parents. The block's own disabled property is not considered. |
| hasDisabledReason | Get whether the block is currently disabled for the provided reason. |
| getDisabledReasons | Get a set of reasons why the block is currently disabled, if any. If the block is enabled, this set will be empty. |
| isCollapsed | Get whether the block is collapsed or not. |
| setAriaRoleDescriptionProvider | Set a custom aria role description provider for this block. If not set, uses a default provider based on the block's properties (e.g. whether it has inputs, outputs, etc.). |
| getAriaRoleDescription | Returns the string to use as the role description for this block. If a custom provider has been set, use that. Otherwise, return a default description based on the block's properties. |
| toString | Create a human-readable text representation of this block and any children. |
| appendValueInput | Appends a value input row. |
| appendStatementInput | Appends a statement input row. |
| appendDummyInput | Appends a dummy input row. |
| appendEndRowInput | Appends an input that ends the row. |
| mixin | Add key/values from mixinObj to this block object. By default, this method will check that the keys in mixinObj will not overwrite existing values in the block, including prototype values. This provides some insurance against mixin / extension incompatibilities with future block features. This check can be disabled by passing true as the second argument. |
| moveInputBefore | Move a named input to a different location on this block. |
| getInput | Fetches the named input object. |
| getInputTargetBlock | Fetches the block attached to the named input. |
| getCommentText | Returns the comment on this block (or null if there is no comment). |
| setCommentText | Set this block's comment text. |
| hasIcon | Returns true if an icon with the given type exists on the block, false otherwise. |
| getIcon | Returns the icon with the given type if it exists on the block, undefined otherwise. |
| getIcons | Returns an array of the icons attached to this block. |
| getRelativeToSurfaceXY | Return the coordinates of the top-left corner of this block relative to the drawing surface's origin (0,0), in workspace units. |
| allInputsFilled | Recursively checks whether all statement and value inputs are filled with blocks. Also checks all following statement blocks in this stack. |
| toDevString | This method returns a string describing this Block in developer terms (type name and ID; English only). |
| initSvg | Create and initialize the SVG representation of the block. May be called more than once. |
| getColourSecondary | Get the secondary colour of a block. |
| getColourTertiary | Get the tertiary colour of a block. |
| select | Selects this block. Highlights the block visually. |
| unselect | Unselects this block. Unhighlights the block visually. |
| moveBy | Move a block by a relative offset. |
| translate | Transforms a block by setting the translation on the transform attribute of the block's SVG. |
| moveTo | Move a block to a position. |
| snapToGrid | Snap this block to the nearest grid point. |
| getBoundingRectangle | Returns the coordinates of a bounding box describing the dimensions of this block and any blocks stacked below it. Coordinate system: workspace coordinates. |
| getBoundingRectangleWithoutChildren | Returns the coordinates of a bounding box describing the dimensions of this block alone. Coordinate system: workspace coordinates. |
| markDirty | Notify every input on this block to mark its fields as dirty. A dirty field is a field that needs to be re-rendered. |
| setCollapsed | Set whether the block is collapsed or not. |
| generateContextMenu | Generate the context menu for this block. |
| calculateContextMenuLocation | Gets the location in which to show the context menu for this block. Use the location of a click if the block was clicked, or a location based on the block's fields otherwise. |
| addClass | Add a CSS class to the SVG group of this block. |
| removeClass | Remove a CSS class from the SVG group of this block. |
| isDragging | Returns whether or not this block is currently being dragged. |
| setMovable | Set whether this block is movable or not. |
| setEditable | Set whether this block is editable or not. |
| getSvgRoot | Return the root node of the SVG or null if none exists. |
| dispose | Dispose of this block. |
| disposeInternal | Disposes of this block without doing things required by the top block. E.g. does trigger UI effects, remove nodes, etc. |
| checkAndDelete | Delete a block and hide chaff when doing so. The block will not be deleted if it's in a flyout. This is called from the context menu and keyboard shortcuts as the full delete action. If you are disposing of a block from the workspace and don't need to perform flyout checks, handle event grouping, or hide chaff, then use block.dispose() directly. |
| toCopyData | Encode a block for copying. |
| setWarningText | Set this block's warning text. |
| setMutator | Give this block a mutator dialog. |
| addIcon | Adds the given icon to the block. |
| removeIcon | Removes the icon whose getType matches the given type iconType from the block. |
| setDisabledReason | Add or remove a reason why the block might be disabled. If a block has any reasons to be disabled, then the block itself will be considered disabled. A block could be disabled for multiple independent reasons simultaneously, such as when the user manually disables it, or the block is invalid. |
| setDeletable | Add blocklyNotDeletable class when block is not deletable Or remove class when block is deletable |
| setHighlighted | Set whether the block is highlighted or not. Block highlighting is often used to visually mark blocks currently being executed. |
| addSelect | Adds the visual "select" effect to the block, but does not actually select it or fire an event. |
| removeSelect | Removes the visual "select" effect from the block, but does not actually unselect it or fire an event. |
| getColour | Get the colour of a block. |
| setColour | Change the colour of a block. |
| setStyle | Set the style and colour values of a block. |
| getStyle | Returns the BlockStyle object used to style this block. |
| bringToFront | Move this block to the front of the visible workspace. |
| setPreviousStatement | Set whether this block can chain onto the bottom of another block. |
| setNextStatement | Set whether another block can chain onto the bottom of this block. |
| setOutput | Set whether this block returns a value. |
| setInputsInline | Set whether value inputs are arranged horizontally or vertically. |
| removeInput | Remove an input from this block. |
| moveNumberedInputBefore | Move a numbered input to a different location on this block. |
| appendInput | Appends the given input row. |
| getNextBlock | Return the next statement block directly connected to this block. |
| getPreviousBlock | Returns the block connected to the previous connection. |
| bumpNeighbours | Bumps unconnected blocks out of alignment. |
| scheduleSnapAndBump | Snap to grid, and then bump neighbouring blocks away at the end of the next render. |
| getChildren | Find all the blocks that are directly nested inside this one. Includes value and statement inputs, as well as any following statement. Excludes any connection on an output tab or any preceding statement. Blocks are optionally sorted by position; top to bottom. |
| render | Immediately lays out and reflows a block based on its contents and settings. |
| setDragStrategy | Sets the drag strategy for this block. |
| isCopyable | Returns whether this block is copyable or not. |
| isMovable | Returns whether this block is movable or not. |
| startDrag | Starts a drag on the block. |
| drag | Drags the block to the given location. |
| endDrag | Ends the drag on the block. |
| revertDrag | Moves the block back to where it was at the start of a drag. |
| toFlyoutInfo | Returns a representation of this block that can be displayed in a flyout. |
| jsonInit | Initialize this block using a cross-platform, internationalization-friendly JSON description. |
| getFocusableElement | See IFocusableNode.getFocusableElement. |
| getFocusableTree | See IFocusableNode.getFocusableTree. |
| onNodeFocus | See IFocusableNode.onNodeFocus. |
| onNodeBlur | See IFocusableNode.onNodeBlur. |
| canBeFocused | See IFocusableNode.canBeFocused. |
| performAction | Handles the user acting on this block via keyboard navigation. If this block is in the flyout, a new copy is spawned in move mode on the main workspace. If this block has a single full-block field, that field will be focused. Otherwise, this is a no-op. |
| getAriaLabel | Returns a description of this block suitable for screenreaders or use in ARIA attributes. |
Constructors
Constructor
new BlockSvg(
workspace,
prototypeName,
opt_id?
): BlockSvg;
Defined in: packages/blockly/core/block_svg.ts:192
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | WorkspaceSvg | The block's workspace. |
prototypeName | string | Name of the language object containing type-specific functions for this block. |
opt_id? | string | Optional ID. Use this ID if provided, otherwise create a new ID. |
Returns
BlockSvg
Overrides
Properties
onchange?
optional onchange?: ((p1) => void) | null;
Defined in: packages/blockly/core/block.ts:63
An optional callback method to use whenever the block's parent workspace changes. This is usually only called from the constructor, the block type initializer function, or an extension initializer function.
Inherited from
COLLAPSED_INPUT_NAME
readonly static COLLAPSED_INPUT_NAME: string = constants.COLLAPSED_INPUT_NAME;
Defined in: packages/blockly/core/block.ts:66
The language-neutral ID given to the collapsed input.
Inherited from
COLLAPSED_FIELD_NAME
readonly static COLLAPSED_FIELD_NAME: string = constants.COLLAPSED_FIELD_NAME;
Defined in: packages/blockly/core/block.ts:69
The language-neutral ID given to the collapsed field.
Inherited from
data
data: string | null = null;
Defined in: packages/blockly/core/block.ts:75
Optional text data that round-trips between blocks and XML. Has no effect. May be used by 3rd parties for meta information.
Inherited from
colour_
protected colour_: string = '#000000';
Defined in: packages/blockly/core/block.ts:91
Colour of the block in '#RRGGBB' format.
Inherited from
styleName_
protected styleName_: string = '';
Defined in: packages/blockly/core/block.ts:94
Name of the block style.
Inherited from
init?
optional init?: () => void;
Defined in: packages/blockly/core/block.ts:97
An optional method called during initialization.
Returns
void
Inherited from
destroy?
optional destroy?: () => void;
Defined in: packages/blockly/core/block.ts:100
An optional method called during disposal.
Returns
void
Inherited from
mutationToDom?
optional mutationToDom?: (...p1) => Element;
Defined in: packages/blockly/core/block.ts:107
An optional serialization method for defining how to serialize the
mutation state to XML. This must be coupled with defining
domToMutation.
Parameters
| Parameter | Type |
|---|---|
...p1 | any[] |
Returns
Element
Inherited from
domToMutation?
optional domToMutation?: (p1) => void;
Defined in: packages/blockly/core/block.ts:114
An optional deserialization method for defining how to deserialize the
mutation state from XML. This must be coupled with defining
mutationToDom.
Parameters
| Parameter | Type |
|---|---|
p1 | Element |
Returns
void
Inherited from
saveExtraState?
optional saveExtraState?: (doFullSerialization?) => any;
Defined in: packages/blockly/core/block.ts:127
An optional serialization method for defining how to serialize the
block's extra state (eg mutation state) to something JSON compatible.
This must be coupled with defining loadExtraState.
Parameters
| Parameter | Type | Description |
|---|---|---|
doFullSerialization? | boolean | Whether or not to serialize the full state of the extra state (rather than possibly saving a reference to some state). This is used during copy-paste. See the block serialization docs for more information. |
Returns
any
Inherited from
loadExtraState?
optional loadExtraState?: (p1) => void;
Defined in: packages/blockly/core/block.ts:134
An optional serialization method for defining how to deserialize the
block's extra state (eg mutation state) from something JSON compatible.
This must be coupled with defining saveExtraState.
Parameters
| Parameter | Type |
|---|---|
p1 | any |
Returns
void
Inherited from
suppressPrefixSuffix
suppressPrefixSuffix: boolean | null = false;
Defined in: packages/blockly/core/block.ts:140
An optional property for suppressing adding STATEMENT_PREFIX and STATEMENT_SUFFIX to generated code.
Inherited from
getDeveloperVariables?
optional getDeveloperVariables?: () => string[];
Defined in: packages/blockly/core/block.ts:149
An optional method for declaring developer variables, to be used by generators. Developer variables are never shown to the user, but are declared as global variables in the generated code.
Returns
string[]
a list of developer variable names.
Inherited from
compose?
optional compose?: (rootBlock) => void;
Defined in: packages/blockly/core/block.ts:157
An optional method that reconfigures the block based on the contents of the mutator dialog.
Parameters
| Parameter | Type | Description |
|---|---|---|
rootBlock | Block | The root block in the mutator flyout. |
Returns
void
Inherited from
id
id: string;
Defined in: packages/blockly/core/block.ts:168
Implementation of
Inherited from
inputList
inputList: Input[] = [];
Defined in: packages/blockly/core/block.ts:172
Inherited from
inputsInline?
optional inputsInline?: boolean;
Defined in: packages/blockly/core/block.ts:173
Inherited from
icons
icons: IIcon[] = [];
Defined in: packages/blockly/core/block.ts:174
Inherited from
tooltip
tooltip: TipInfo = '';
Defined in: packages/blockly/core/block.ts:176
Inherited from
contextMenu
contextMenu: boolean = true;
Defined in: packages/blockly/core/block.ts:177
Inherited from
parentBlock_
protected parentBlock_: BlockSvg | null = null;
Defined in: packages/blockly/core/block.ts:179
Inherited from
childBlocks_
protected childBlocks_: BlockSvg[] = [];
Defined in: packages/blockly/core/block.ts:181
Inherited from
collapsed_
protected collapsed_: boolean = false;
Defined in: packages/blockly/core/block.ts:191
Inherited from
outputShape_
protected outputShape_: number | null = null;
Defined in: packages/blockly/core/block.ts:192
Inherited from
disposing
protected disposing: boolean = false;
Defined in: packages/blockly/core/block.ts:197
Is the current block currently in the process of being disposed?
Inherited from
xy
protected readonly xy: Coordinate;
Defined in: packages/blockly/core/block.ts:206
Inherited from
isInFlyout
isInFlyout: boolean;
Defined in: packages/blockly/core/block.ts:207
Inherited from
isInMutator
isInMutator: boolean;
Defined in: packages/blockly/core/block.ts:208
Inherited from
RTL
RTL: boolean;
Defined in: packages/blockly/core/block.ts:209
Inherited from
isInsertionMarker_
protected isInsertionMarker_: boolean = false;
Defined in: packages/blockly/core/block.ts:212
True if this block is an insertion marker.
Inherited from
hat?
optional hat?: string;
Defined in: packages/blockly/core/block.ts:215
Name of the type of hat.
Inherited from
helpUrl
helpUrl: string | (() => string) | null = null;
Defined in: packages/blockly/core/block.ts:223
String for block help, or function that returns a URL. Null for no help.
Inherited from
type
type: string;
Defined in: packages/blockly/core/block.ts:235
Inherited from
inputsInlineDefault?
optional inputsInlineDefault?: boolean;
Defined in: packages/blockly/core/block.ts:237
Inherited from
INLINE
readonly static INLINE: -1 = -1;
Defined in: packages/blockly/core/block_svg.ts:92
Constant for identifying rows that are to be rendered inline. Don't collide with Blockly.inputTypes.
COLLAPSED_WARNING_ID
readonly static COLLAPSED_WARNING_ID: "TEMP_COLLAPSED_WARNING_" = 'TEMP_COLLAPSED_WARNING_';
Defined in: packages/blockly/core/block_svg.ts:99
ID to give the "collapsed warnings" warning. Allows us to remove the "collapsed warnings" warning without removing any warnings that belong to the block.
decompose?
optional decompose?: (p1) => BlockSvg;
Defined in: packages/blockly/core/block_svg.ts:100
An optional function that populates the mutator flyout with blocks representing this block's configuration.
Parameters
| Parameter | Type |
|---|---|
p1 | Workspace |
Returns
BlockSvg
The root block created in the flyout's workspace.
Overrides
saveConnections?
optional saveConnections?: (rootBlock) => void;
Defined in: packages/blockly/core/block_svg.ts:119
An optional method which saves a record of blocks connected to this block so they can be later restored after this block is recoomposed (reconfigured). Typically records the connected blocks on properties on blocks in the mutator flyout, so that rearranging those component blocks will automatically rearrange the corresponding connected blocks on this block after this block is recomposed.
To keep the saved connection information up-to-date, MutatorIcon arranges for an event listener to call this method any time the mutator flyout is open and a change occurs on this block's workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
rootBlock | BlockSvg | The root block in the mutator flyout. |
Returns
void
customContextMenu?
optional customContextMenu?: (p1) => void;
Defined in: packages/blockly/core/block_svg.ts:121
Parameters
| Parameter | Type |
|---|---|
p1 | ( | ContextMenuOption | LegacyContextMenuOption)[] |
Returns
void
height
height: number = 0;
Defined in: packages/blockly/core/block_svg.ts:129
Height of this block, not including any statement blocks above or below. Height is in workspace units.
width
width: number = 0;
Defined in: packages/blockly/core/block_svg.ts:135
Width of this block, including any connected value blocks. Width is in workspace units.
mutator
mutator: MutatorIcon | null = null;
Defined in: packages/blockly/core/block_svg.ts:152
Block's mutator icon (if any).
style
style: BlockStyle;
Defined in: packages/blockly/core/block_svg.ts:155
rendered
readonly rendered: true = true;
Defined in: packages/blockly/core/block_svg.ts:160
Is this block a BlockSVG?
Overrides
workspace
workspace: WorkspaceSvg;
Defined in: packages/blockly/core/block_svg.ts:164
Implementation of
Overrides
outputConnection
outputConnection: RenderedConnection | null = null;
Defined in: packages/blockly/core/block_svg.ts:165
Overrides
nextConnection
nextConnection: RenderedConnection | null = null;
Defined in: packages/blockly/core/block_svg.ts:166
Overrides
previousConnection
previousConnection: RenderedConnection | null = null;
Defined in: packages/blockly/core/block_svg.ts:167
Overrides
Methods
doInit_()
protected doInit_(): void;
Defined in: packages/blockly/core/block.ts:287
Calls the init() function and handles associated event firing, etc.
Returns
void
Inherited from
initModel()
initModel(): void;
Defined in: packages/blockly/core/block.ts:389
Call initModel on all fields on the block. May be called more than once. Either initModel or initSvg must be called after creating a block and before the first interaction with it. Interactions include UI actions (e.g. clicking and dragging) and firing events (e.g. create, delete, and change).
Returns
void
Inherited from
unplug()
unplug(opt_healStack?): void;
Defined in: packages/blockly/core/block.ts:404
Unplug this block from its superior block. If this block is a statement, optionally reconnect the block underneath with the block on top.
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_healStack? | boolean | Disconnect child statement and reconnect stack. Defaults to false. |
Returns
void
Inherited from
getParent()
getParent(): BlockSvg | null;
Defined in: packages/blockly/core/block.ts:594
Return the parent block or null if this block is at the top level. The parent block is either the block connected to the previous connection (for a statement block) or the block connected to the output connection (for a value block).
Returns
BlockSvg | null
The block (if any) that holds the current block.
Inherited from
getInputWithBlock()
getInputWithBlock(block): Input | null;
Defined in: packages/blockly/core/block.ts:604
Return the input that connects to the specified block.
Parameters
| Parameter | Type | Description |
|---|---|---|
block | Block | A block connected to an input on this block. |
Returns
Input | null
The input (if any) that connects to the specified block.
Inherited from
getSurroundParent()
getSurroundParent(): BlockSvg | null;
Defined in: packages/blockly/core/block.ts:621
Return the parent block that surrounds the current block, or null if this block has no surrounding block. A parent block might just be the previous statement, whereas the surrounding block is an if statement, while loop, etc.
Returns
BlockSvg | null
The block (if any) that surrounds the current block.
Inherited from
getRootBlock()
getRootBlock(): this;
Defined in: packages/blockly/core/block.ts:661
Return the top-most block in this block's tree. This will return itself if this block is at the top level.
Returns
this
The root block.
Inherited from
getDescendants()
getDescendants(ordered): BlockSvg[];
Defined in: packages/blockly/core/block.ts:784
Find all the blocks that are directly or indirectly nested inside this one. Includes this block in the list. Includes value and statement inputs, as well as any following statements. Excludes any connection on an output tab or any preceding statements. Blocks are optionally sorted by position; top to bottom.
Parameters
| Parameter | Type | Description |
|---|---|---|
ordered | boolean | Sort the list if true. |
Returns
BlockSvg[]
Flattened array of blocks.
Inherited from
isDeletable()
isDeletable(): boolean;
Defined in: packages/blockly/core/block.ts:800
Get whether this block is deletable or not.
Returns
boolean
True if deletable.
Implementation of
Inherited from
isOwnDeletable()
isOwnDeletable(): boolean;
Defined in: packages/blockly/core/block.ts:815
Return whether this block's own deletable property is true or false.
Returns
boolean
True if the block's deletable property is true, false otherwise.
Inherited from
isDuplicatable()
isDuplicatable(): boolean;
Defined in: packages/blockly/core/block.ts:871
Get whether is block is duplicatable or not. If duplicating this block and descendants will put this block over the workspace's capacity this block is not duplicatable. If duplicating this block and descendants will put any type over their maxInstances this block is not duplicatable.
Returns
boolean
True if duplicatable.
Inherited from
isShadow()
isShadow(): boolean;
Defined in: packages/blockly/core/block.ts:885
Get whether this block is a shadow block or not.
Returns
boolean
True if a shadow.
Inherited from
isInsertionMarker()
isInsertionMarker(): boolean;
Defined in: packages/blockly/core/block.ts:906
Get whether this block is an insertion marker block or not.
Returns
boolean
True if an insertion marker.
Inherited from
isOwnEditable()
isOwnEditable(): boolean;
Defined in: packages/blockly/core/block.ts:938
Return whether this block's own editable property is true or false.
Returns
boolean
True if the block's editable property is true, false otherwise.
Inherited from
isDisposed()
isDisposed(): boolean;
Defined in: packages/blockly/core/block.ts:959
Returns if this block has been disposed of / deleted.
Returns
boolean
True if this block has been disposed of / deleted.
Inherited from
setHelpUrl()
setHelpUrl(url): void;
Defined in: packages/blockly/core/block.ts:1032
Set the URL of this block's help page.
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | (() => string) | URL string for block help, or function that returns a URL. Null for no help. |
Returns
void
Inherited from
setTooltip()
setTooltip(newTip): void;
Defined in: packages/blockly/core/block.ts:1043
Sets the tooltip for this block.
Parameters
| Parameter | Type | Description |
|---|---|---|
newTip | TipInfo | The text for the tooltip, a function that returns the text for the tooltip, or a parent object whose tooltip will be used. To not display a tooltip pass the empty string. |
Returns
void
Inherited from
getTooltip()
getTooltip(): string;
Defined in: packages/blockly/core/block.ts:1052
Returns the tooltip text for this block.
Returns
string
The tooltip text for this block.
Inherited from
getStyleName()
getStyleName(): string;
Defined in: packages/blockly/core/block.ts:1070
Get the name of the block style.
Returns
string
Name of the block style.
Inherited from
getHue()
getHue(): number | null;
Defined in: packages/blockly/core/block.ts:1079
Get the HSV hue value of a block. Null if hue not set.
Returns
number | null
Hue value (0-360).
Inherited from
setOnChange()
setOnChange(onchangeFn): void;
Defined in: packages/blockly/core/block.ts:1113
Sets a callback function to use whenever the block's parent workspace changes, replacing any prior onchange handler. This is usually only called from the constructor, the block type initializer function, or an extension initializer function.
Parameters
| Parameter | Type | Description |
|---|---|---|
onchangeFn | (p1) => void | The callback to call when the block's workspace changes. |
Returns
void
Throws
if onchangeFn is not falsey and not a function.
Inherited from
getField()
getField(name): Field<any> | null;
Defined in: packages/blockly/core/block.ts:1131
Returns the named field from a block.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the field. |
Returns
Field<any> | null
Named field, or null if field does not exist.
Inherited from
getFields()
getFields(): Generator<Field<any>, undefined, void>;
Defined in: packages/blockly/core/block.ts:1153
Returns a generator that provides every field on the block.
Returns
Generator<Field<any>, undefined, void>
A generator that can be used to iterate the fields on the block.
Inherited from
getVarModels()
getVarModels(): IVariableModel<IVariableState>[];
Defined in: packages/blockly/core/block.ts:1166
Return all variables referenced by this block.
Returns
IVariableModel<IVariableState>[]
List of variable models.
Inherited from
renameVarById()
renameVarById(oldId, newId): void;
Defined in: packages/blockly/core/block.ts:1209
Notification that a variable is renaming. If the ID matches one of this block's variables, rename it.
Parameters
| Parameter | Type | Description |
|---|---|---|
oldId | string | ID of variable to rename. |
newId | string | ID of new variable. May be the same as oldId, but with an updated name. |
Returns
void
Inherited from
getFieldValue()
getFieldValue(name): any;
Defined in: packages/blockly/core/block.ts:1223
Returns the language-neutral value of the given field.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the field. |
Returns
any
Value of the field or null if field does not exist.
Inherited from
setFieldValue()
setFieldValue(newValue, name): void;
Defined in: packages/blockly/core/block.ts:1237
Sets the value of the given field for this block.
Parameters
| Parameter | Type | Description |
|---|---|---|
newValue | any | The value to set. |
name | string | The name of the field to set the value of. |
Returns
void
Inherited from
getInputsInline()
getInputsInline(): boolean;
Defined in: packages/blockly/core/block.ts:1367
Get whether value inputs are arranged horizontally or vertically.
Returns
boolean
True if inputs are horizontal.
Inherited from
setOutputShape()
setOutputShape(outputShape): void;
Defined in: packages/blockly/core/block.ts:1405
Set the block's output shape.
Parameters
| Parameter | Type | Description |
|---|---|---|
outputShape | number | null | Value representing an output shape. |
Returns
void
Inherited from
getOutputShape()
getOutputShape(): number | null;
Defined in: packages/blockly/core/block.ts:1414
Get the block's output shape.
Returns
number | null
Value representing output shape if one exists.
Inherited from
isEnabled()
isEnabled(): boolean;
Defined in: packages/blockly/core/block.ts:1426
Get whether this block is enabled or not. A block is considered enabled if there aren't any reasons why it would be disabled. A block may still be disabled for other reasons even if the user attempts to manually enable it, such as when the block is in an invalid location.
Returns
boolean
True if enabled.
Inherited from
getInheritedDisabled()
getInheritedDisabled(): boolean;
Defined in: packages/blockly/core/block.ts:1488
Get whether the block is disabled or not due to parents. The block's own disabled property is not considered.
Returns
boolean
True if disabled.
Inherited from
hasDisabledReason()
hasDisabledReason(reason): boolean;
Defined in: packages/blockly/core/block.ts:1507
Get whether the block is currently disabled for the provided reason.
Parameters
| Parameter | Type | Description |
|---|---|---|
reason | string | A language-neutral identifier for a reason why the block could be disabled. |
Returns
boolean
Whether the block is disabled for the provided reason.
Inherited from
getDisabledReasons()
getDisabledReasons(): ReadonlySet<string>;
Defined in: packages/blockly/core/block.ts:1517
Get a set of reasons why the block is currently disabled, if any. If the block is enabled, this set will be empty.
Returns
ReadonlySet<string>
The set of reasons why the block is disabled, if any.
Inherited from
isCollapsed()
isCollapsed(): boolean;
Defined in: packages/blockly/core/block.ts:1526
Get whether the block is collapsed or not.
Returns
boolean
True if collapsed.
Inherited from
setAriaRoleDescriptionProvider()
setAriaRoleDescriptionProvider(description): void;
Defined in: packages/blockly/core/block.ts:1560
Set a custom aria role description provider for this block. If not set, uses a default provider based on the block's properties (e.g. whether it has inputs, outputs, etc.).
Parameters
| Parameter | Type | Description |
|---|---|---|
description | string | (() => string) | The description or function to provide the description. If a string, we'll replace message references in the string, e.g. %{BKY_CUSTOM_MESSAGE} will be replaced with the value of Blockly.Msg['CUSTOM_MESSAGE'].}' |
Returns
void
Inherited from
Block.setAriaRoleDescriptionProvider
getAriaRoleDescription()
getAriaRoleDescription(): string;
Defined in: packages/blockly/core/block.ts:1569
Returns
string
The string to use as the role description for this block. If a custom provider has been set, use that. Otherwise, return a default description based on the block's properties.
Inherited from
toString()
toString(opt_maxLength?, opt_emptyToken?): string;
Defined in: packages/blockly/core/block.ts:1596
Create a human-readable text representation of this block and any children.
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_maxLength? | number | Truncate the string to this length. |
opt_emptyToken? | string | The placeholder string used to denote an empty input. If not specified, '?' is used. |
Returns
string
Text of block.
Inherited from
appendValueInput()
appendValueInput(name): Input;
Defined in: packages/blockly/core/block.ts:1683
Appends a value input row.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Language-neutral identifier which may used to find this input again. Should be unique to this block. |
Returns
The input object created.
Inherited from
appendStatementInput()
appendStatementInput(name): Input;
Defined in: packages/blockly/core/block.ts:1694
Appends a statement input row.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Language-neutral identifier which may used to find this input again. Should be unique to this block. |
Returns
The input object created.
Inherited from
appendDummyInput()
appendDummyInput(name?): Input;
Defined in: packages/blockly/core/block.ts:1706
Appends a dummy input row.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
name | string | '' | Optional language-neutral identifier which may used to find this input again. Should be unique to this block. |
Returns
The input object created.
Inherited from
appendEndRowInput()
appendEndRowInput(name?): Input;
Defined in: packages/blockly/core/block.ts:1717
Appends an input that ends the row.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
name | string | '' | Optional language-neutral identifier which may used to find this input again. Should be unique to this block. |
Returns
The input object created.
Inherited from
mixin()
mixin(mixinObj, opt_disableCheck?): void;
Defined in: packages/blockly/core/block.ts:1917
Add key/values from mixinObj to this block object. By default, this method will check that the keys in mixinObj will not overwrite existing values in the block, including prototype values. This provides some insurance against mixin / extension incompatibilities with future block features. This check can be disabled by passing true as the second argument.
Parameters
| Parameter | Type | Description |
|---|---|---|
mixinObj | any | The key/values pairs to add to this block object. |
opt_disableCheck? | boolean | Option flag to disable overwrite checks. |
Returns
void
Inherited from
moveInputBefore()
moveInputBefore(name, refName): void;
Defined in: packages/blockly/core/block.ts:2223
Move a named input to a different location on this block.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the input to move. |
refName | string | null | Name of input that should be after the moved input, or null to be the input at the end. |
Returns
void
Inherited from
getInput()
getInput(name): Input | null;
Defined in: packages/blockly/core/block.ts:2309
Fetches the named input object.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the input. |
Returns
Input | null
The input object, or null if input does not exist.
Inherited from
getInputTargetBlock()
getInputTargetBlock(name): Block | null;
Defined in: packages/blockly/core/block.ts:2326
Fetches the block attached to the named input.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the input. |
Returns
Block | null
The attached value block, or null if the input is either disconnected or if the input does not exist.
Inherited from
getCommentText()
getCommentText(): string | null;
Defined in: packages/blockly/core/block.ts:2336
Returns the comment on this block (or null if there is no comment).
Returns
string | null
Block's comment.
Inherited from
setCommentText()
setCommentText(text): void;
Defined in: packages/blockly/core/block.ts:2346
Set this block's comment text.
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | null | The text, or null to delete. |
Returns
void
Inherited from
hasIcon()
hasIcon(type): boolean;
Defined in: packages/blockly/core/block.ts:2436
Parameters
| Parameter | Type |
|---|---|
type | IconType<IIcon> |
Returns
boolean
True if an icon with the given type exists on the block, false otherwise.
Inherited from
getIcon()
getIcon<T>(type): T | undefined;
Defined in: packages/blockly/core/block.ts:2446
Type Parameters
| Type Parameter |
|---|
T extends IIcon |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | string | IconType<T> | The type of the icon to retrieve. Prefer passing an IconType for proper type checking when using typescript. |
Returns
T | undefined
The icon with the given type if it exists on the block, undefined otherwise.
Inherited from
getIcons()
getIcons(): IIcon[];
Defined in: packages/blockly/core/block.ts:2455
Returns
IIcon[]
An array of the icons attached to this block.
Inherited from
getRelativeToSurfaceXY()
getRelativeToSurfaceXY(): Coordinate;
Defined in: packages/blockly/core/block.ts:2465
Return the coordinates of the top-left corner of this block relative to the drawing surface's origin (0,0), in workspace units.
Returns
Object with .x and .y properties.
Implementation of
IDraggable.getRelativeToSurfaceXY
Inherited from
allInputsFilled()
allInputsFilled(opt_shadowBlocksAreFilled?): boolean;
Defined in: packages/blockly/core/block.ts:2506
Recursively checks whether all statement and value inputs are filled with blocks. Also checks all following statement blocks in this stack.
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_shadowBlocksAreFilled? | boolean | An optional argument controlling whether shadow blocks are counted as filled. Defaults to true. |
Returns
boolean
True if all inputs are filled, false otherwise.
Inherited from
toDevString()
toDevString(): string;
Defined in: packages/blockly/core/block.ts:2545
This method returns a string describing this Block in developer terms (type name and ID; English only).
Intended to on be used in console logs and errors. If you need a string that uses the user's native language (including block text, field values, and child blocks), use (Block:class).toString | toString().
Returns
string
The description.
Inherited from
initSvg()
initSvg(): void;
Defined in: packages/blockly/core/block_svg.ts:228
Create and initialize the SVG representation of the block. May be called more than once.
Returns
void
getColourSecondary()
getColourSecondary(): string;
Defined in: packages/blockly/core/block_svg.ts:256
Get the secondary colour of a block.
Returns
string
#RRGGBB string.
getColourTertiary()
getColourTertiary(): string;
Defined in: packages/blockly/core/block_svg.ts:265
Get the tertiary colour of a block.
Returns
string
#RRGGBB string.
select()
select(): void;
Defined in: packages/blockly/core/block_svg.ts:270
Selects this block. Highlights the block visually.
Returns
void
Implementation of
unselect()
unselect(): void;
Defined in: packages/blockly/core/block_svg.ts:276
Unselects this block. Unhighlights the block visually.
Returns
void
Implementation of
moveBy()
moveBy(
dx,
dy,
reason?
): void;
Defined in: packages/blockly/core/block_svg.ts:343
Move a block by a relative offset.
Parameters
| Parameter | Type | Description |
|---|---|---|
dx | number | Horizontal offset in workspace units. |
dy | number | Vertical offset in workspace units. |
reason? | string[] | Why is this move happening? 'drag', 'bump', 'snap', ... |
Returns
void
Implementation of
Overrides
translate()
translate(x, y): void;
Defined in: packages/blockly/core/block_svg.ts:376
Transforms a block by setting the translation on the transform attribute of the block's SVG.
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | The x coordinate of the translation in workspace units. |
y | number | The y coordinate of the translation in workspace units. |
Returns
void
moveTo()
moveTo(xy, reason?): void;
Defined in: packages/blockly/core/block_svg.ts:397
Move a block to a position.
Parameters
| Parameter | Type | Description |
|---|---|---|
xy | Coordinate | The position to move to in workspace units. |
reason? | string[] | Why is this move happening? 'drag', 'bump', 'snap', ... |
Returns
void
snapToGrid()
snapToGrid(): void;
Defined in: packages/blockly/core/block_svg.ts:415
Snap this block to the nearest grid point.
Returns
void
getBoundingRectangle()
getBoundingRectangle(): Rect;
Defined in: packages/blockly/core/block_svg.ts:435
Returns the coordinates of a bounding box describing the dimensions of this block and any blocks stacked below it. Coordinate system: workspace coordinates.
Returns
Object with coordinates of the bounding box.
Implementation of
IDraggable.getBoundingRectangle
getBoundingRectangleWithoutChildren()
getBoundingRectangleWithoutChildren(): Rect;
Defined in: packages/blockly/core/block_svg.ts:446
Returns the coordinates of a bounding box describing the dimensions of this block alone. Coordinate system: workspace coordinates.
Returns
Object with coordinates of the bounding box.
markDirty()
markDirty(): void;
Defined in: packages/blockly/core/block_svg.ts:474
Notify every input on this block to mark its fields as dirty. A dirty field is a field that needs to be re-rendered.
Returns
void
setCollapsed()
setCollapsed(collapsed): void;
Defined in: packages/blockly/core/block_svg.ts:486
Set whether the block is collapsed or not.
Parameters
| Parameter | Type | Description |
|---|---|---|
collapsed | boolean | True if collapsed. |
Returns
void
Overrides
generateContextMenu()
protected generateContextMenu(e):
| (
| ContextMenuOption
| LegacyContextMenuOption)[]
| null;
Defined in: packages/blockly/core/block_svg.ts:599
Generate the context menu for this block.
Parameters
| Parameter | Type |
|---|---|
e | Event |
Returns
| (
| ContextMenuOption
| LegacyContextMenuOption)[]
| null
Context menu options or null if no menu.
calculateContextMenuLocation()
protected calculateContextMenuLocation(e): Coordinate;
Defined in: packages/blockly/core/block_svg.ts:623
Gets the location in which to show the context menu for this block. Use the location of a click if the block was clicked, or a location based on the block's fields otherwise.
Parameters
| Parameter | Type |
|---|---|
e | Event |
Returns
addClass()
addClass(className): void;
Defined in: packages/blockly/core/block_svg.ts:732
Add a CSS class to the SVG group of this block.
Parameters
| Parameter | Type |
|---|---|
className | string |
Returns
void
removeClass()
removeClass(className): void;
Defined in: packages/blockly/core/block_svg.ts:741
Remove a CSS class from the SVG group of this block.
Parameters
| Parameter | Type |
|---|---|
className | string |
Returns
void
isDragging()
isDragging(): boolean;
Defined in: packages/blockly/core/block_svg.ts:774
Returns whether or not this block is currently being dragged.
Returns
boolean
setMovable()
setMovable(movable): void;
Defined in: packages/blockly/core/block_svg.ts:783
Set whether this block is movable or not.
Parameters
| Parameter | Type | Description |
|---|---|---|
movable | boolean | True if movable. |
Returns
void
Overrides
setEditable()
setEditable(editable): void;
Defined in: packages/blockly/core/block_svg.ts:793
Set whether this block is editable or not.
Parameters
| Parameter | Type | Description |
|---|---|---|
editable | boolean | True if editable. |
Returns
void
Overrides
getSvgRoot()
getSvgRoot(): SVGGElement;
Defined in: packages/blockly/core/block_svg.ts:847
Return the root node of the SVG or null if none exists.
Returns
SVGGElement
The root SVG node (probably a group).
dispose()
dispose(healStack?, animate?): void;
Defined in: packages/blockly/core/block_svg.ts:885
Dispose of this block.
Parameters
| Parameter | Type | Description |
|---|---|---|
healStack? | boolean | If true, then try to heal any gap by connecting the next statement with the previous statement. Otherwise, dispose of all children of this block. |
animate? | boolean | If true, show a disposal animation and sound. |
Returns
void
Implementation of
Overrides
disposeInternal()
disposeInternal(): void;
Defined in: packages/blockly/core/block_svg.ts:951
Disposes of this block without doing things required by the top block. E.g. does trigger UI effects, remove nodes, etc.
Returns
void
Overrides
checkAndDelete()
checkAndDelete(): void;
Defined in: packages/blockly/core/block_svg.ts:972
Delete a block and hide chaff when doing so. The block will not be deleted
if it's in a flyout. This is called from the context menu and keyboard
shortcuts as the full delete action. If you are disposing of a block from
the workspace and don't need to perform flyout checks, handle event
grouping, or hide chaff, then use block.dispose() directly.
Returns
void
toCopyData()
toCopyData(addNextBlocks?):
| BlockCopyData
| null;
Defined in: packages/blockly/core/block_svg.ts:996
Encode a block for copying.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
addNextBlocks | boolean | false | If true, copy subsequent blocks attached to this one as well. |
Returns
| BlockCopyData
| null
Copy metadata, or null if the block is an insertion marker.
Implementation of
setWarningText()
setWarningText(text, id?): void;
Defined in: packages/blockly/core/block_svg.ts:1058
Set this block's warning text.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
text | string | null | undefined | The text, or null to delete. |
id | string | '' | An optional ID for the warning text to be able to maintain multiple warnings. |
Returns
void
Overrides
setMutator()
setMutator(mutator): void;
Defined in: packages/blockly/core/block_svg.ts:1130
Give this block a mutator dialog.
Parameters
| Parameter | Type | Description |
|---|---|---|
mutator | MutatorIcon | null | A mutator dialog instance or null to remove. |
Returns
void
Overrides
addIcon()
addIcon<T>(icon): T;
Defined in: packages/blockly/core/block_svg.ts:1135
Adds the given icon to the block.
Type Parameters
| Type Parameter |
|---|
T extends IIcon |
Parameters
| Parameter | Type |
|---|---|
icon | T |
Returns
T
Overrides
removeIcon()
removeIcon(type): boolean;
Defined in: packages/blockly/core/block_svg.ts:1164
Removes the icon whose getType matches the given type iconType from the block.
Parameters
| Parameter | Type | Description |
|---|---|---|
type | IconType<IIcon> | The type of the icon to remove from the block. |
Returns
boolean
True if an icon with the given type was found, false otherwise.
Overrides
setDisabledReason()
setDisabledReason(disabled, reason): void;
Defined in: packages/blockly/core/block_svg.ts:1188
Add or remove a reason why the block might be disabled. If a block has any reasons to be disabled, then the block itself will be considered disabled. A block could be disabled for multiple independent reasons simultaneously, such as when the user manually disables it, or the block is invalid.
Parameters
| Parameter | Type | Description |
|---|---|---|
disabled | boolean | If true, then the block should be considered disabled for at least the provided reason, otherwise the block is no longer disabled for that reason. |
reason | string | A language-neutral identifier for a reason why the block could be disabled. Call this method again with the same identifier to update whether the block is currently disabled for this reason. |
Returns
void
Overrides
setDeletable()
setDeletable(deletable): void;
Defined in: packages/blockly/core/block_svg.ts:1200
Add blocklyNotDeletable class when block is not deletable Or remove class when block is deletable
Parameters
| Parameter | Type |
|---|---|
deletable | boolean |
Returns
void
Overrides
setHighlighted()
setHighlighted(highlighted): void;
Defined in: packages/blockly/core/block_svg.ts:1216
Set whether the block is highlighted or not. Block highlighting is often used to visually mark blocks currently being executed.
Parameters
| Parameter | Type | Description |
|---|---|---|
highlighted | boolean | True if highlighted. |
Returns
void
addSelect()
addSelect(): void;
Defined in: packages/blockly/core/block_svg.ts:1226
Adds the visual "select" effect to the block, but does not actually select it or fire an event.
Returns
void
See
BlockSvg#select
removeSelect()
removeSelect(): void;
Defined in: packages/blockly/core/block_svg.ts:1236
Removes the visual "select" effect from the block, but does not actually unselect it or fire an event.
Returns
void
See
BlockSvg#unselect
getColour()
getColour(): string;
Defined in: packages/blockly/core/block_svg.ts:1258
Get the colour of a block.
Returns
string
#RRGGBB string.
Overrides
setColour()
setColour(colour): void;
Defined in: packages/blockly/core/block_svg.ts:1267
Change the colour of a block.
Parameters
| Parameter | Type | Description |
|---|---|---|
colour | string | number | HSV hue value, or #RRGGBB string. |
Returns
void
Overrides
setStyle()
setStyle(blockStyleName): void;
Defined in: packages/blockly/core/block_svg.ts:1287
Set the style and colour values of a block.
Parameters
| Parameter | Type | Description |
|---|---|---|
blockStyleName | string | Name of the block style. |
Returns
void
Throws
if the block style does not exist.
Overrides
getStyle()
getStyle(): BlockStyle;
Defined in: packages/blockly/core/block_svg.ts:1318
Returns the BlockStyle object used to style this block.
Returns
This block's style object.
bringToFront()
bringToFront(blockOnly?): void;
Defined in: packages/blockly/core/block_svg.ts:1333
Move this block to the front of the visible workspace.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
blockOnly | boolean | false | True to only move this block to the front without adjusting its parents. |
Returns
void
setPreviousStatement()
setPreviousStatement(newBoolean, opt_check?): void;
Defined in: packages/blockly/core/block_svg.ts:1390
Set whether this block can chain onto the bottom of another block.
Parameters
| Parameter | Type | Description |
|---|---|---|
newBoolean | boolean | True if there can be a previous statement. |
opt_check? | string | string[] | null | Statement type or list of statement types. Null/undefined if any type could be connected. |
Returns
void
Overrides
setNextStatement()
setNextStatement(newBoolean, opt_check?): void;
Defined in: packages/blockly/core/block_svg.ts:1405
Set whether another block can chain onto the bottom of this block.
Parameters
| Parameter | Type | Description |
|---|---|---|
newBoolean | boolean | True if there can be a next statement. |
opt_check? | string | string[] | null | Statement type or list of statement types. Null/undefined if any type could be connected. |
Returns
void
Overrides
setOutput()
setOutput(newBoolean, opt_check?): void;
Defined in: packages/blockly/core/block_svg.ts:1420
Set whether this block returns a value.
Parameters
| Parameter | Type | Description |
|---|---|---|
newBoolean | boolean | True if there is an output. |
opt_check? | string | string[] | null | Returned type or list of returned types. Null or undefined if any type could be returned (e.g. variable get). |
Returns
void
Overrides
setInputsInline()
setInputsInline(newBoolean): void;
Defined in: packages/blockly/core/block_svg.ts:1433
Set whether value inputs are arranged horizontally or vertically.
Parameters
| Parameter | Type | Description |
|---|---|---|
newBoolean | boolean | True if inputs are horizontal. |
Returns
void
Overrides
removeInput()
removeInput(name, opt_quiet?): boolean;
Defined in: packages/blockly/core/block_svg.ts:1447
Remove an input from this block.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the input. |
opt_quiet? | boolean | True to prevent error if input is not present. |
Returns
boolean
True if operation succeeds, false if input is not present and opt_quiet is true
Throws
if the input is not present and opt_quiet is not true.
Overrides
moveNumberedInputBefore()
moveNumberedInputBefore(inputIndex, refIndex): void;
Defined in: packages/blockly/core/block_svg.ts:1459
Move a numbered input to a different location on this block.
Parameters
| Parameter | Type | Description |
|---|---|---|
inputIndex | number | Index of the input to move. |
refIndex | number | Index of input that should be after the moved input. |
Returns
void
Overrides
appendInput()
appendInput(input): Input;
Defined in: packages/blockly/core/block_svg.ts:1464
Appends the given input row.
Allows for custom inputs to be appended to the block.
Parameters
| Parameter | Type |
|---|---|
input | Input |
Returns
Overrides
getNextBlock()
getNextBlock(): BlockSvg | null;
Defined in: packages/blockly/core/block_svg.ts:1594
Return the next statement block directly connected to this block.
Returns
BlockSvg | null
The next statement block or null.
Overrides
getPreviousBlock()
getPreviousBlock(): BlockSvg | null;
Defined in: packages/blockly/core/block_svg.ts:1603
Returns the block connected to the previous connection.
Returns
BlockSvg | null
The previous statement block or null.
Overrides
bumpNeighbours()
bumpNeighbours(): void;
Defined in: packages/blockly/core/block_svg.ts:1613
Bumps unconnected blocks out of alignment.
Two blocks which aren't actually connected should not coincidentally line up on screen, because that creates confusion for end-users.
Returns
void
Overrides
scheduleSnapAndBump()
scheduleSnapAndBump(): void;
Defined in: packages/blockly/core/block_svg.ts:1651
Snap to grid, and then bump neighbouring blocks away at the end of the next render.
Returns
void
getChildren()
getChildren(ordered): BlockSvg[];
Defined in: packages/blockly/core/block_svg.ts:1697
Find all the blocks that are directly nested inside this one. Includes value and statement inputs, as well as any following statement. Excludes any connection on an output tab or any preceding statement. Blocks are optionally sorted by position; top to bottom.
Parameters
| Parameter | Type | Description |
|---|---|---|
ordered | boolean | Sort the list if true. |
Returns
BlockSvg[]
Array of blocks.
Overrides
render()
render(): void;
Defined in: packages/blockly/core/block_svg.ts:1717
Immediately lays out and reflows a block based on its contents and settings.
Returns
void
setDragStrategy()
setDragStrategy(dragStrategy): void;
Defined in: packages/blockly/core/block_svg.ts:1808
Sets the drag strategy for this block.
Parameters
| Parameter | Type |
|---|---|
dragStrategy | IDragStrategy |
Returns
void
isCopyable()
isCopyable(): boolean;
Defined in: packages/blockly/core/block_svg.ts:1813
Returns whether this block is copyable or not.
Returns
boolean
Implementation of
isMovable()
isMovable(): boolean;
Defined in: packages/blockly/core/block_svg.ts:1818
Returns whether this block is movable or not.
Returns
boolean
Implementation of
Overrides
Block.isMovable
startDrag()
startDrag(e?): IDraggable;
Defined in: packages/blockly/core/block_svg.ts:1823
Starts a drag on the block.
Parameters
| Parameter | Type |
|---|---|
e? | PointerEvent | KeyboardEvent |
Returns
Implementation of
drag()
drag(newLoc, e?): void;
Defined in: packages/blockly/core/block_svg.ts:1828
Drags the block to the given location.
Parameters
| Parameter | Type |
|---|---|
newLoc | Coordinate |
e? | PointerEvent | KeyboardEvent |
Returns
void
Implementation of
endDrag()
endDrag(e, disposition): void;
Defined in: packages/blockly/core/block_svg.ts:1833
Ends the drag on the block.
Parameters
| Parameter | Type |
|---|---|
e | PointerEvent | KeyboardEvent | undefined |
disposition | DragDisposition |
Returns
void
Implementation of
revertDrag()
revertDrag(): void;
Defined in: packages/blockly/core/block_svg.ts:1841
Moves the block back to where it was at the start of a drag.
Returns
void
Implementation of
toFlyoutInfo()
toFlyoutInfo(): FlyoutItemInfo[];
Defined in: packages/blockly/core/block_svg.ts:1848
Returns a representation of this block that can be displayed in a flyout.
Returns
jsonInit()
jsonInit(json): void;
Defined in: packages/blockly/core/block_svg.ts:1871
Initialize this block using a cross-platform, internationalization-friendly JSON description.
Parameters
| Parameter | Type | Description |
|---|---|---|
json | any | Structured data describing the block. |
Returns
void
Overrides
getFocusableElement()
getFocusableElement(): HTMLElement | SVGElement;
Defined in: packages/blockly/core/block_svg.ts:1894
See IFocusableNode.getFocusableElement.
Returns
HTMLElement | SVGElement
Implementation of
IFocusableNode.getFocusableElement
getFocusableTree()
getFocusableTree(): IFocusableTree;
Defined in: packages/blockly/core/block_svg.ts:1904
See IFocusableNode.getFocusableTree.
Returns
Implementation of
IFocusableNode.getFocusableTree
onNodeFocus()
onNodeFocus(): void;
Defined in: packages/blockly/core/block_svg.ts:1909
See IFocusableNode.onNodeFocus.
Returns
void
Implementation of
onNodeBlur()
onNodeBlur(): void;
Defined in: packages/blockly/core/block_svg.ts:1926
See IFocusableNode.onNodeBlur.
Returns
void
Implementation of
canBeFocused()
canBeFocused(): boolean;
Defined in: packages/blockly/core/block_svg.ts:1931
See IFocusableNode.canBeFocused.
Returns
boolean
Implementation of
performAction()
performAction(e?): void;
Defined in: packages/blockly/core/block_svg.ts:1941
Handles the user acting on this block via keyboard navigation. If this block is in the flyout, a new copy is spawned in move mode on the main workspace. If this block has a single full-block field, that field will be focused. Otherwise, this is a no-op.
Parameters
| Parameter | Type |
|---|---|
e? | KeyboardEvent |
Returns
void
Implementation of
getAriaLabel()
getAriaLabel(verbosity): string;
Defined in: packages/blockly/core/block_svg.ts:2046
Returns a description of this block suitable for screenreaders or use in ARIA attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
verbosity | Verbosity | How much detail to include in the description. |
Returns
string
An accessibility description of this block.