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()

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.

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()