Skip to main content

blockly > icons > Icon

icons.Icon class

The abstract icon class. Icons are visual elements that live in the top-start corner of the block. Usually they provide more "meta" information about a block (such as warnings or comments) as opposed to fields, which provide "actual" information, related to how a block functions.

Signature:

export declare abstract class Icon implements IIcon, IContextMenu

Implements: IIcon, IContextMenu

Constructors

Constructor

Modifiers

Description

(constructor)(sourceBlock)

Constructs a new instance of the Icon class

Properties

Property

Modifiers

Type

Description

offsetInBlock

protected

Coordinate

The position of this icon relative to its blocks top-start, in workspace units.

sourceBlock

protected

Block

svgRoot

protected

SVGGElement | null

The root svg element visually representing this icon.

tooltip

protected

tooltip.TipInfo

The tooltip for this icon.

workspaceLocation

protected

Coordinate

The position of this icon in workspace coordinates.

Methods

Method

Modifiers

Description

applyColour()

canBeFocused()

See IFocusableNode.canBeFocused.

dispose()

getAriaLabel()

protected

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.

getFocusableElement()

See IFocusableNode.getFocusableElement.

getFocusableTree()

See IFocusableNode.getFocusableTree.

getSize()

getSourceBlock()

Returns the block that this icon is attached to.

getTooltip()

Returns the tooltip for this icon.

getType()

getWeight()

hideForInsertionMarker()

initView(pointerdownListener)

isClickableInFlyout(autoClosingFlyout)

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.

isShownWhenCollapsed()

onClick()

onLocationChange(blockOrigin)

onNodeBlur()

See IFocusableNode.onNodeBlur.

onNodeFocus()

See IFocusableNode.onNodeFocus.

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.

recomputeAriaContext()

protected

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.

setOffsetInBlock(offset)

setTooltip(tip)

Sets the tooltip for this icon to the given value. Null to show the tooltip of the block.

showContextMenu(e)

updateCollapsed()

updateEditable()