Class: MutatorIcon
Defined in: packages/blockly/core/icons/mutator_icon.ts:44
An icon that allows the user to change the shape of the block.
For example, it could be used to add additional fields or inputs to the block.
Extends
Implements
Properties index
| Property | Description |
|---|---|
| offsetInBlock | The position of this icon relative to its blocks top-start, in workspace units. |
| workspaceLocation | The position of this icon in workspace coordinates. |
| svgRoot | The root svg element visually representing this icon. |
| tooltip | The tooltip for this icon. |
| TYPE | The type string used to identify this icon. |
| WEIGHT | The weight this icon has relative to other icons. Icons with more positive weight values are rendered farther toward the end of the block. |
| sourceBlock | - |
Methods index
| Method | Description |
|---|---|
| setTooltip | Sets the tooltip for this icon to the given value. Null to show the tooltip of the block. |
| getTooltip | Returns the tooltip for this icon. |
| updateEditable | Updates the icon's editability when the block's editability changes. |
| hideForInsertionMarker | Hides the icon when it is part of an insertion marker. |
| isShownWhenCollapsed | Returns whether this icon is shown when the block is collapsed. Used to allow renderers to account for padding. |
| setOffsetInBlock | Notifies the icon where it is relative to its block's top-start, in workspace units. |
| 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 icon via keyboard navigation. Performs the same action as a click would, and focuses this icon's bubble if it has one. |
| getSourceBlock | Returns the block that this icon is attached to. |
| showContextMenu | Show the context menu for this object. |
| recomputeAriaContext | Recomputes the ARIA label and role for this icon. This is automatically called during initialization, but implementations may find it useful to call this if the icon's label should be changed. |
| getType | Returns the IconType representing the type of the icon. This value should also be used to register the icon via Blockly.icons.registry.register. |
| initView | Creates the SVG elements for the icon that will live on the block. |
| dispose | Disposes of any elements of the icon. |
| getWeight | Returns the "weight" of the icon, which determines the static order which icons should be rendered in. More positive numbers are rendered farther toward the end of the block. |
| getSize | Returns the dimensions of the icon for use in rendering. |
| applyColour | Updates the icon's color when the block's color changes.. |
| updateCollapsed | Updates the icon's collapsed-ness/view when the block's collapsed-ness changes. |
| onLocationChange | Notifies the icon that it has changed locations. |
| onClick | Notifies the icon that it has been clicked. |
| isClickableInFlyout | Check whether the icon should be clickable while the block is in a flyout. The default is that icons are clickable in all flyouts (auto-closing or not). Subclasses may override this function to change this behavior. |
| bubbleIsVisible | Returns true if the bubble is currently open, false otherwise. |
| setBubbleVisible | Sets whether the bubble is open or not. |
| getBubble | See IHasBubble.getBubble. |
| getWorkspace | Returns the workspace of the mini workspace bubble, if the bubble is currently open. |
| getAriaLabel | Returns the ARIA label to use for this icon (defaults to null). Note that this method will only be called during initialization by default, so dynamic changes to the icon's ARIA label need to be applied by calling recomputeAriaContext. |
Constructors
Constructor
new MutatorIcon(flyoutBlockTypes, sourceBlock): MutatorIcon;
Defined in: packages/blockly/core/icons/mutator_icon.ts:72
Parameters
| Parameter | Type |
|---|---|
flyoutBlockTypes | string[] |
sourceBlock | BlockSvg |
Returns
MutatorIcon
Overrides
Properties
offsetInBlock
protected offsetInBlock: Coordinate;
Defined in: packages/blockly/core/icons/icon.ts:39
The position of this icon relative to its blocks top-start, in workspace units.
Inherited from
workspaceLocation
protected workspaceLocation: Coordinate;
Defined in: packages/blockly/core/icons/icon.ts:42
The position of this icon in workspace coordinates.
Inherited from
svgRoot
protected svgRoot: SVGGElement | null = null;
Defined in: packages/blockly/core/icons/icon.ts:45
The root svg element visually representing this icon.
Inherited from
tooltip
protected tooltip: TipInfo;
Defined in: packages/blockly/core/icons/icon.ts:48
The tooltip for this icon.
Inherited from
TYPE
readonly static TYPE: IconType<MutatorIcon> = IconType.MUTATOR;
Defined in: packages/blockly/core/icons/mutator_icon.ts:46
The type string used to identify this icon.
WEIGHT
readonly static WEIGHT: 1 = 1;
Defined in: packages/blockly/core/icons/mutator_icon.ts:52
The weight this icon has relative to other icons. Icons with more positive weight values are rendered farther toward the end of the block.
sourceBlock
protected readonly sourceBlock: BlockSvg;
Defined in: packages/blockly/core/icons/mutator_icon.ts:74
Inherited from
Methods
setTooltip()
setTooltip(tip): void;
Defined in: packages/blockly/core/icons/icon.ts:104
Sets the tooltip for this icon to the given value. Null to show the tooltip of the block.
Parameters
| Parameter | Type |
|---|---|
tip | TipInfo | null |
Returns
void
Inherited from
getTooltip()
getTooltip(): TipInfo;
Defined in: packages/blockly/core/icons/icon.ts:109
Returns the tooltip for this icon.
Returns
Inherited from
updateEditable()
updateEditable(): void;
Defined in: packages/blockly/core/icons/icon.ts:115
Updates the icon's editability when the block's editability changes.
Returns
void
Inherited from
hideForInsertionMarker()
hideForInsertionMarker(): void;
Defined in: packages/blockly/core/icons/icon.ts:129
Hides the icon when it is part of an insertion marker.
Returns
void
Inherited from
isShownWhenCollapsed()
isShownWhenCollapsed(): boolean;
Defined in: packages/blockly/core/icons/icon.ts:134
Returns
boolean
Whether this icon is shown when the block is collapsed. Used to allow renderers to account for padding.
Inherited from
setOffsetInBlock()
setOffsetInBlock(offset): void;
Defined in: packages/blockly/core/icons/icon.ts:138
Notifies the icon where it is relative to its block's top-start, in workspace units.
Parameters
| Parameter | Type |
|---|---|
offset | Coordinate |
Returns
void
Inherited from
getFocusableElement()
getFocusableElement(): HTMLElement | SVGElement;
Defined in: packages/blockly/core/icons/icon.ts:170
See IFocusableNode.getFocusableElement.
Returns
HTMLElement | SVGElement
Inherited from
getFocusableTree()
getFocusableTree(): IFocusableTree;
Defined in: packages/blockly/core/icons/icon.ts:177
See IFocusableNode.getFocusableTree.
Returns
Inherited from
onNodeFocus()
onNodeFocus(): void;
Defined in: packages/blockly/core/icons/icon.ts:182
See IFocusableNode.onNodeFocus.
Returns
void
Inherited from
onNodeBlur()
onNodeBlur(): void;
Defined in: packages/blockly/core/icons/icon.ts:194
See IFocusableNode.onNodeBlur.
Returns
void
Inherited from
canBeFocused()
canBeFocused(): boolean;
Defined in: packages/blockly/core/icons/icon.ts:197
See IFocusableNode.canBeFocused.
Returns
boolean
Inherited from
performAction()
performAction(): void;
Defined in: packages/blockly/core/icons/icon.ts:206
Handles the user acting on this icon via keyboard navigation. Performs the same action as a click would, and focuses this icon's bubble if it has one.
Returns
void
Inherited from
getSourceBlock()
getSourceBlock(): Block;
Defined in: packages/blockly/core/icons/icon.ts:222
Returns the block that this icon is attached to.
Returns
The block this icon is attached to.
Inherited from
showContextMenu()
showContextMenu(e): void;
Defined in: packages/blockly/core/icons/icon.ts:226
Show the context menu for this object.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | PointerEvent | Mouse event. |
Returns
void
Inherited from
recomputeAriaContext()
protected recomputeAriaContext(): void;
Defined in: packages/blockly/core/icons/icon.ts:235
Recomputes the ARIA label and role for this icon. This is automatically called during initialization, but implementations may find it useful to call this if the icon's label should be changed.
Returns
void
Inherited from
getType()
getType(): IconType<MutatorIcon>;
Defined in: packages/blockly/core/icons/mutator_icon.ts:79
Returns
IconType<MutatorIcon>
the IconType representing the type of the icon. This value should
also be used to register the icon via Blockly.icons.registry.register.
Overrides
initView()
initView(pointerdownListener): void;
Defined in: packages/blockly/core/icons/mutator_icon.ts:83
Creates the SVG elements for the icon that will live on the block.
Parameters
| Parameter | Type | Description |
|---|---|---|
pointerdownListener | (e) => void | An event listener that must be attached to the root SVG element by the implementation of initView. Used by Blockly's gesture system to properly handle clicks and drags. |
Returns
void
Overrides
dispose()
dispose(): void;
Defined in: packages/blockly/core/icons/mutator_icon.ts:125
Disposes of any elements of the icon.
Returns
void
Remarks
In particular, if this icon is currently showing a bubble, this should be used to hide it.
Overrides
getWeight()
getWeight(): number;
Defined in: packages/blockly/core/icons/mutator_icon.ts:130
Returns
number
the "weight" of the icon, which determines the static order which icons should be rendered in. More positive numbers are rendered farther toward the end of the block.
Overrides
getSize()
getSize(): Size;
Defined in: packages/blockly/core/icons/mutator_icon.ts:134
Returns
The dimensions of the icon for use in rendering.
Overrides
applyColour()
applyColour(): void;
Defined in: packages/blockly/core/icons/mutator_icon.ts:138
Updates the icon's color when the block's color changes..
Returns
void
Overrides
updateCollapsed()
updateCollapsed(): void;
Defined in: packages/blockly/core/icons/mutator_icon.ts:144
Updates the icon's collapsed-ness/view when the block's collapsed-ness changes.
Returns
void
Overrides
onLocationChange()
onLocationChange(blockOrigin): void;
Defined in: packages/blockly/core/icons/mutator_icon.ts:149
Notifies the icon that it has changed locations.
Parameters
| Parameter | Type | Description |
|---|---|---|
blockOrigin | Coordinate | The location of this icon's block's top-start corner in workspace coordinates. |
Returns
void
Overrides
onClick()
onClick(): void;
Defined in: packages/blockly/core/icons/mutator_icon.ts:154
Notifies the icon that it has been clicked.
Returns
void
Overrides
isClickableInFlyout()
isClickableInFlyout(): boolean;
Defined in: packages/blockly/core/icons/mutator_icon.ts:161
Check whether the icon should be clickable while the block is in a flyout. The default is that icons are clickable in all flyouts (auto-closing or not). Subclasses may override this function to change this behavior.
Returns
boolean
Whether the icon should be clickable while the block is in a flyout.
Overrides
bubbleIsVisible()
bubbleIsVisible(): boolean;
Defined in: packages/blockly/core/icons/mutator_icon.ts:165
Returns
boolean
True if the bubble is currently open, false otherwise.
Implementation of
setBubbleVisible()
setBubbleVisible(visible): Promise<void>;
Defined in: packages/blockly/core/icons/mutator_icon.ts:169
Sets whether the bubble is open or not.
Parameters
| Parameter | Type |
|---|---|
visible | boolean |
Returns
Promise<void>
Implementation of
getBubble()
getBubble():
| MiniWorkspaceBubble
| null;
Defined in: packages/blockly/core/icons/mutator_icon.ts:213
See IHasBubble.getBubble.
Returns
| MiniWorkspaceBubble
| null
Implementation of
getWorkspace()
getWorkspace(): WorkspaceSvg | undefined;
Defined in: packages/blockly/core/icons/mutator_icon.ts:363
Returns
WorkspaceSvg | undefined
The workspace of the mini workspace bubble, if the bubble is currently open.
getAriaLabel()
protected getAriaLabel(): string | null;
Defined in: packages/blockly/core/icons/mutator_icon.ts:374
Returns the ARIA label to use for this icon (defaults to null). Note that this method will only be called during initialization by default, so dynamic changes to the icon's ARIA label need to be applied by calling recomputeAriaContext.
Returns
string | null
The ARIA label to use for this icon, or null to use a default.