Skip to main content

Class: CommentIcon

Defined in: packages/blockly/core/icons/comment_icon.ts:40

An icon which allows the user to add comment text to a block.

Extends

Implements

Properties index

PropertyDescription
TYPEThe type string used to identify this icon.
WEIGHTThe weight this icon has relative to other icons. Icons with more positive weight values are rendered farther toward the end of the block.
sourceBlock-
offsetInBlockThe position of this icon relative to its blocks top-start, in workspace units.
workspaceLocationThe position of this icon in workspace coordinates.
svgRootThe root svg element visually representing this icon.
tooltipThe tooltip for this icon.

Methods index

MethodDescription
getTypeReturns the IconType representing the type of the icon. This value should also be used to register the icon via Blockly.icons.registry.register.
initViewCreates the SVG elements for the icon that will live on the block.
disposeDisposes of any elements of the icon.
getWeightReturns 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.
getSizeReturns the dimensions of the icon for use in rendering.
applyColourUpdates the icon's color when the block's color changes..
updateEditableUpdates the state of the bubble (editable / noneditable) to reflect the state of the bubble if the bubble is currently shown.
onLocationChangeNotifies the icon that it has changed locations.
setTextSets the text of this comment. Updates any bubbles if they are visible.
getTextReturns the text of this comment.
setBubbleSizeSets the size of the editable bubble for this comment. Resizes the bubble if it is visible.
getBubbleSizeReturns the size of the editable bubble for this comment.
setBubbleLocationSets the location of the comment bubble in the workspace.
getBubbleLocationReturns the location of the comment bubble in the workspace.
saveStateReturns the state of the comment as a JSON serializable value if the comment has text. Otherwise returns null.
loadStateApplies the given state to this comment.
onClickNotifies the icon that it has been clicked.
isClickableInFlyoutCheck 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.
onTextChangeUpdates the text of this comment in response to changes in the text of the input bubble.
onSizeChangeUpdates the size of this icon in response to changes in the size of the input bubble.
onBubbleLocationChange-
bubbleIsVisibleReturns true if the bubble is currently open, false otherwise.
setBubbleVisibleSets whether the bubble is open or not.
getBubbleSee IHasBubble.getBubble.
createBubble-
getAriaLabelReturns 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.
setTooltipSets the tooltip for this icon to the given value. Null to show the tooltip of the block.
getTooltipReturns the tooltip for this icon.
updateCollapsedUpdates the icon's collapsed-ness/view when the block's collapsed-ness changes.
hideForInsertionMarkerHides the icon when it is part of an insertion marker.
isShownWhenCollapsedReturns whether this icon is shown when the block is collapsed. Used to allow renderers to account for padding.
setOffsetInBlockNotifies the icon where it is relative to its block's top-start, in workspace units.
getFocusableElementSee IFocusableNode.getFocusableElement.
getFocusableTreeSee IFocusableNode.getFocusableTree.
onNodeFocusSee IFocusableNode.onNodeFocus.
onNodeBlurSee IFocusableNode.onNodeBlur.
canBeFocusedSee IFocusableNode.canBeFocused.
performActionHandles 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.
getSourceBlockReturns the block that this icon is attached to.
showContextMenuShow the context menu for this object.
recomputeAriaContextRecomputes 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.

Constructors

Constructor

new CommentIcon(sourceBlock): CommentIcon;

Defined in: packages/blockly/core/icons/comment_icon.ts:71

Parameters

ParameterType
sourceBlockBlock

Returns

CommentIcon

Overrides

Icon.constructor

Properties

TYPE

readonly static TYPE: IconType<ICommentIcon> = IconType.COMMENT;

Defined in: packages/blockly/core/icons/comment_icon.ts:42

The type string used to identify this icon.


WEIGHT

readonly static WEIGHT: 3 = 3;

Defined in: packages/blockly/core/icons/comment_icon.ts:48

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: Block;

Defined in: packages/blockly/core/icons/comment_icon.ts:71

Inherited from

Icon.sourceBlock


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

Icon.offsetInBlock


workspaceLocation

protected workspaceLocation: Coordinate;

Defined in: packages/blockly/core/icons/icon.ts:42

The position of this icon in workspace coordinates.

Inherited from

Icon.workspaceLocation


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

WarningIcon.svgRoot


tooltip

protected tooltip: TipInfo;

Defined in: packages/blockly/core/icons/icon.ts:48

The tooltip for this icon.

Inherited from

Icon.tooltip

Methods

getType()

getType(): IconType<CommentIcon>;

Defined in: packages/blockly/core/icons/comment_icon.ts:75

Returns

IconType<CommentIcon>

the IconType representing the type of the icon. This value should also be used to register the icon via Blockly.icons.registry.register.

Overrides

Icon.getType


initView()

initView(pointerdownListener): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:79

Creates the SVG elements for the icon that will live on the block.

Parameters

ParameterTypeDescription
pointerdownListener(e) => voidAn 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

Icon.initView


dispose()

dispose(): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:118

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

Icon.dispose


getWeight()

getWeight(): number;

Defined in: packages/blockly/core/icons/comment_icon.ts:123

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

Icon.getWeight


getSize()

getSize(): Size;

Defined in: packages/blockly/core/icons/comment_icon.ts:127

Returns

Size

The dimensions of the icon for use in rendering.

Overrides

Icon.getSize


applyColour()

applyColour(): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:131

Updates the icon's color when the block's color changes..

Returns

void

Overrides

Icon.applyColour


updateEditable()

updateEditable(): Promise<void>;

Defined in: packages/blockly/core/icons/comment_icon.ts:141

Updates the state of the bubble (editable / noneditable) to reflect the state of the bubble if the bubble is currently shown.

Returns

Promise<void>

Overrides

Icon.updateEditable


onLocationChange()

onLocationChange(blockOrigin): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:150

Notifies the icon that it has changed locations.

Parameters

ParameterTypeDescription
blockOriginCoordinateThe location of this icon's block's top-start corner in workspace coordinates.

Returns

void

Overrides

Icon.onLocationChange


setText()

setText(text): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:163

Sets the text of this comment. Updates any bubbles if they are visible.

Parameters

ParameterType
textstring

Returns

void


getText()

getText(): string;

Defined in: packages/blockly/core/icons/comment_icon.ts:179

Returns the text of this comment.

Returns

string


setBubbleSize()

setBubbleSize(size): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:187

Sets the size of the editable bubble for this comment. Resizes the bubble if it is visible.

Parameters

ParameterType
sizeSize

Returns

void


getBubbleSize()

getBubbleSize(): Size;

Defined in: packages/blockly/core/icons/comment_icon.ts:193

Returns

Size

the size of the editable bubble for this comment.


setBubbleLocation()

setBubbleLocation(location): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:200

Sets the location of the comment bubble in the workspace.

Parameters

ParameterType
locationCoordinate

Returns

void


getBubbleLocation()

getBubbleLocation(): Coordinate | undefined;

Defined in: packages/blockly/core/icons/comment_icon.ts:208

Returns

Coordinate | undefined

the location of the comment bubble in the workspace.


saveState()

saveState(): CommentState | null;

Defined in: packages/blockly/core/icons/comment_icon.ts:216

Returns

CommentState | null

the state of the comment as a JSON serializable value if the comment has text. Otherwise returns null.

Implementation of

ISerializable.saveState


loadState()

loadState(state): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:238

Applies the given state to this comment.

Parameters

ParameterType
stateCommentState

Returns

void

Implementation of

ISerializable.loadState


onClick()

onClick(): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:258

Notifies the icon that it has been clicked.

Returns

void

Overrides

Icon.onClick


isClickableInFlyout()

isClickableInFlyout(): boolean;

Defined in: packages/blockly/core/icons/comment_icon.ts:263

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

Icon.isClickableInFlyout


onTextChange()

onTextChange(): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:271

Updates the text of this comment in response to changes in the text of the input bubble.

Returns

void


onSizeChange()

onSizeChange(): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:293

Updates the size of this icon in response to changes in the size of the input bubble.

Returns

void


onBubbleLocationChange()

onBubbleLocationChange(): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:299

Returns

void


bubbleIsVisible()

bubbleIsVisible(): boolean;

Defined in: packages/blockly/core/icons/comment_icon.ts:305

Returns

boolean

True if the bubble is currently open, false otherwise.

Implementation of

IHasBubble.bubbleIsVisible


setBubbleVisible()

setBubbleVisible(visible): Promise<void>;

Defined in: packages/blockly/core/icons/comment_icon.ts:309

Sets whether the bubble is open or not.

Parameters

ParameterType
visibleboolean

Returns

Promise<void>

Implementation of

IHasBubble.setBubbleVisible


getBubble()

getBubble(): TextInputBubble | null;

Defined in: packages/blockly/core/icons/comment_icon.ts:346

See IHasBubble.getBubble.

Returns

TextInputBubble | null

Implementation of

IHasBubble.getBubble


createBubble()

protected createBubble(): void;

Defined in: packages/blockly/core/icons/comment_icon.ts:366

Returns

void


getAriaLabel()

protected getAriaLabel(): string | null;

Defined in: packages/blockly/core/icons/comment_icon.ts:422

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.

Overrides

Icon.getAriaLabel


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

ParameterType
tipTipInfo | null

Returns

void

Inherited from

Icon.setTooltip


getTooltip()

getTooltip(): TipInfo;

Defined in: packages/blockly/core/icons/icon.ts:109

Returns the tooltip for this icon.

Returns

TipInfo

Inherited from

Icon.getTooltip


updateCollapsed()

updateCollapsed(): void;

Defined in: packages/blockly/core/icons/icon.ts:117

Updates the icon's collapsed-ness/view when the block's collapsed-ness changes.

Returns

void

Inherited from

Icon.updateCollapsed


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

Icon.hideForInsertionMarker


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

Icon.isShownWhenCollapsed


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

ParameterType
offsetCoordinate

Returns

void

Inherited from

Icon.setOffsetInBlock


getFocusableElement()

getFocusableElement(): HTMLElement | SVGElement;

Defined in: packages/blockly/core/icons/icon.ts:170

See IFocusableNode.getFocusableElement.

Returns

HTMLElement | SVGElement

Inherited from

Icon.getFocusableElement


getFocusableTree()

getFocusableTree(): IFocusableTree;

Defined in: packages/blockly/core/icons/icon.ts:177

See IFocusableNode.getFocusableTree.

Returns

IFocusableTree

Inherited from

Icon.getFocusableTree


onNodeFocus()

onNodeFocus(): void;

Defined in: packages/blockly/core/icons/icon.ts:182

See IFocusableNode.onNodeFocus.

Returns

void

Inherited from

Icon.onNodeFocus


onNodeBlur()

onNodeBlur(): void;

Defined in: packages/blockly/core/icons/icon.ts:194

See IFocusableNode.onNodeBlur.

Returns

void

Inherited from

Icon.onNodeBlur


canBeFocused()

canBeFocused(): boolean;

Defined in: packages/blockly/core/icons/icon.ts:197

See IFocusableNode.canBeFocused.

Returns

boolean

Inherited from

Icon.canBeFocused


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

Icon.performAction


getSourceBlock()

getSourceBlock(): Block;

Defined in: packages/blockly/core/icons/icon.ts:222

Returns the block that this icon is attached to.

Returns

Block

The block this icon is attached to.

Inherited from

Icon.getSourceBlock


showContextMenu()

showContextMenu(e): void;

Defined in: packages/blockly/core/icons/icon.ts:226

Show the context menu for this object.

Parameters

ParameterTypeDescription
ePointerEventMouse event.

Returns

void

Inherited from

Icon.showContextMenu


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

Icon.recomputeAriaContext