Stay organized with collections
Save and categorize content based on your preferences.
blockly > icons > WarningIcon
icons.WarningIcon class
An icon that warns the user that something is wrong with their block.
For example, this could be used to warn them about incorrect field values, or incorrect placement of the block (putting it somewhere it doesn't belong).
Signature:
export declare class WarningIcon extends Icon implements IHasBubble
Extends: Icon
Implements: IHasBubble
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the WarningIcon
class.
Properties
Property |
Modifiers |
Type |
Description |
sourceBlock |
protected
readonly
|
BlockSvg |
|
TYPE |
static
readonly
|
IconType<WarningIcon> |
The type string used to identify this icon. |
WEIGHT |
static
readonly
|
(not declared) |
The weight this icon has relative to other icons. Icons with more positive weight values are rendered farther toward the end of the block. |
Methods
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eWarningIcon\u003c/code\u003e class in Blockly is used to display a warning icon on blocks, indicating potential issues like incorrect field values or placement.\u003c/p\u003e\n"],["\u003cp\u003eThis icon is visually represented by a warning symbol and can have an associated bubble to provide more detailed information.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eWarningIcon\u003c/code\u003e inherits from the \u003ccode\u003eIcon\u003c/code\u003e class and implements the \u003ccode\u003eIHasBubble\u003c/code\u003e interface, allowing it to display and manage a warning bubble.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers should not directly instantiate or extend the \u003ccode\u003eWarningIcon\u003c/code\u003e class, as its constructor is marked as internal.\u003c/p\u003e\n"],["\u003cp\u003eThe icon's weight property influences its rendering position relative to other icons on the block.\u003c/p\u003e\n"]]],["The `WarningIcon` class, extending `Icon` and implementing `IHasBubble`, alerts users to issues with a block, such as incorrect values or placement. It has properties like `sourceBlock`, `TYPE`, and `WEIGHT`. Key methods include `onClick` to toggle bubble visibility, `onLocationChange` to update the bubble's position, and `isShownWhenCollapsed` to determine if it's visible when the block is collapsed. This class should not be constructed or extended directly by third-party code.\n"],null,["[blockly](./blockly.md) \\\u003e [icons](./blockly.icons_namespace.md) \\\u003e [WarningIcon](./blockly.icons_namespace.warningicon_class.md)\n\nicons.WarningIcon class\n-----------------------\n\nAn icon that warns the user that something is wrong with their block.\n\nFor example, this could be used to warn them about incorrect field values, or incorrect placement of the block (putting it somewhere it doesn't belong).\n\n**Signature:** \n\n export declare class WarningIcon extends Icon implements IHasBubble \n\n**Extends:** [Icon](./blockly.icons_namespace.icon_class.md)\n\n**Implements:** [IHasBubble](./blockly.ihasbubble_interface.md)\n\nRemarks\n-------\n\nThe constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `WarningIcon` class.\n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|------------------------------------------------------------------------------------|------------------------|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| [sourceBlock](./blockly.icons_namespace.warningicon_class.sourceblock_property.md) | `protected` `readonly` | [BlockSvg](./blockly.blocksvg_class.md) | |\n| [TYPE](./blockly.icons_namespace.warningicon_class.type_property.md) | `static` `readonly` | [IconType](./blockly.icons_namespace.icontype_class.md)\\\u003c[WarningIcon](./blockly.icons_namespace.warningicon_class.md)\\\u003e | The type string used to identify this icon. |\n| [WEIGHT](./blockly.icons_namespace.warningicon_class.weight_property.md) | `static` `readonly` | (not declared) | The weight this icon has relative to other icons. Icons with more positive weight values are rendered farther toward the end of the block. |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|-----------------------------------------------------------------------------------------------------------|-----------|--------------------------------------------------------------------|\n| [applyColour()](./blockly.icons_namespace.warningicon_class.applycolour_1_method.md) | | |\n| [bubbleIsVisible()](./blockly.icons_namespace.warningicon_class.bubbleisvisible_1_method.md) | | |\n| [dispose()](./blockly.icons_namespace.warningicon_class.dispose_1_method.md) | | |\n| [getBubble()](./blockly.icons_namespace.warningicon_class.getbubble_1_method.md) | | See IHasBubble.getBubble. |\n| [getSize()](./blockly.icons_namespace.warningicon_class.getsize_1_method.md) | | |\n| [getType()](./blockly.icons_namespace.warningicon_class.gettype_1_method.md) | | |\n| [getWeight()](./blockly.icons_namespace.warningicon_class.getweight_1_method.md) | | |\n| [initView(pointerdownListener)](./blockly.icons_namespace.warningicon_class.initview_1_method.md) | | |\n| [isClickableInFlyout()](./blockly.icons_namespace.warningicon_class.isclickableinflyout_1_method.md) | | |\n| [isShownWhenCollapsed()](./blockly.icons_namespace.warningicon_class.isshownwhencollapsed_1_method.md) | | Tells blockly that this icon is shown when the block is collapsed. |\n| [onClick()](./blockly.icons_namespace.warningicon_class.onclick_1_method.md) | | Toggles the visibility of the bubble. |\n| [onLocationChange(blockOrigin)](./blockly.icons_namespace.warningicon_class.onlocationchange_1_method.md) | | Updates the location of the icon's bubble if it is open. |\n| [setBubbleVisible(visible)](./blockly.icons_namespace.warningicon_class.setbubblevisible_1_method.md) | | |\n| [updateCollapsed()](./blockly.icons_namespace.warningicon_class.updatecollapsed_1_method.md) | | |"]]