Skip to main content

Home > 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 

Implements: IIcon

Constructors

ConstructorModifiersDescription
(constructor)(sourceBlock)Constructs a new instance of the Icon class

Properties

PropertyModifiersTypeDescription
offsetInBlockprotectedCoordinateThe position of this icon relative to its blocks top-start, in workspace units.
sourceBlockprotectedBlock
svgRootprotectedSVGGElement | nullThe root svg element visually representing this icon.
tooltipprotectedtooltip.TipInfoThe tooltip for this icon.
workspaceLocationprotectedCoordinateThe position of this icon in workspace coordinates.

Methods

MethodModifiersDescription
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.
updateCollapsed()
updateEditable()