Stay organized with collections
Save and categorize content based on your preferences.
blockly > ToolboxItem
Class for an item in the toolbox.
Signature:
export declare class ToolboxItem implements IToolboxItem
Implements: IToolboxItem
Constructors
Properties
Methods
Method |
Modifiers |
Description |
canBeFocused() |
|
See IFocusableNode.canBeFocused. |
dispose() |
|
Dispose of this toolbox item. No-op by default. |
getClickTarget() |
|
Gets the HTML element that is clickable. The parent toolbox element receives clicks. The parent toolbox will add an ID to this element so it can pass the onClick event to the correct toolboxItem. |
getDiv() |
|
Gets the div for the toolbox item. |
getFocusableElement() |
|
See IFocusableNode.getFocusableElement. |
getFocusableTree() |
|
See IFocusableNode.getFocusableTree. |
getId() |
|
Gets a unique identifier for this toolbox item. |
getParent() |
|
Gets the parent if the toolbox item is nested. |
init() |
|
Initializes the toolbox item. This includes creating the DOM and updating the state of any items based on the info object. |
isCollapsible() |
|
Whether the toolbox item is collapsible. |
isSelectable() |
|
Whether the toolbox item is selectable. |
onNodeBlur() |
|
See IFocusableNode.onNodeBlur. |
onNodeFocus() |
|
See IFocusableNode.onNodeFocus. |
setVisible_(_isVisible) |
|
Sets whether the category is visible or not. For a category to be visible its parent category must also be expanded. |
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\u003eToolboxItem\u003c/code\u003e class represents an item within the Blockly toolbox, inheriting from the \u003ccode\u003eIToolboxItem\u003c/code\u003e interface.\u003c/p\u003e\n"],["\u003cp\u003eIt manages the creation, initialization, and interaction of toolbox items, including their visibility, selectability, and click handling.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eToolboxItem\u003c/code\u003e can have a parent, allowing for nested structures and collapsible categories within the toolbox.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access and manipulate properties like ID, parent, and associated workspace, as well as call methods to manage the item's lifecycle and behavior.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [ToolboxItem](./blockly.toolboxitem_class.md)\n\nToolboxItem class\n-----------------\n\nClass for an item in the toolbox.\n\n**Signature:** \n\n export declare class ToolboxItem implements IToolboxItem \n\n**Implements:** [IToolboxItem](./blockly.itoolboxitem_interface.md)\n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|------------------------------------------------------------------------------------------------------------------------|-----------|------------------------------------------------------|\n| [(constructor)(toolboxItemDef, parentToolbox, opt_parent)](./blockly.toolboxitem_class._constructor__1_constructor.md) | | Constructs a new instance of the `ToolboxItem` class |\n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|----------------------------------------------------------------------------|------------------------|-------------------------------------------------------------------------------------------------------------|---------------------------------------|\n| [id_](./blockly.toolboxitem_class.id__property.md) | `protected` | string | |\n| [level_](./blockly.toolboxitem_class.level__property.md) | `protected` | number | |\n| [parent_](./blockly.toolboxitem_class.parent__property.md) | `protected` | [ICollapsibleToolboxItem](./blockly.icollapsibletoolboxitem_interface.md) \\| null | |\n| [parentToolbox_](./blockly.toolboxitem_class.parenttoolbox__property.md) | `protected` `readonly` | [IToolbox](./blockly.itoolbox_interface.md) | The toolbox this category belongs to. |\n| [toolboxItemDef_](./blockly.toolboxitem_class.toolboxitemdef__property.md) | `protected` | [toolbox.ToolboxItemInfo](./blockly.utils_namespace.toolbox_namespace.toolboxiteminfo_typealias.md) \\| null | |\n| [workspace_](./blockly.toolboxitem_class.workspace__property.md) | `protected` | [WorkspaceSvg](./blockly.workspacesvg_class.md) | |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|--------------------------------------------------------------------------------------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [canBeFocused()](./blockly.toolboxitem_class.canbefocused_1_method.md) | | See IFocusableNode.canBeFocused. |\n| [dispose()](./blockly.toolboxitem_class.dispose_1_method.md) | | Dispose of this toolbox item. No-op by default. |\n| [getClickTarget()](./blockly.toolboxitem_class.getclicktarget_1_method.md) | | Gets the HTML element that is clickable. The parent toolbox element receives clicks. The parent toolbox will add an ID to this element so it can pass the onClick event to the correct toolboxItem. |\n| [getDiv()](./blockly.toolboxitem_class.getdiv_1_method.md) | | Gets the div for the toolbox item. |\n| [getFocusableElement()](./blockly.toolboxitem_class.getfocusableelement_1_method.md) | | See IFocusableNode.getFocusableElement. |\n| [getFocusableTree()](./blockly.toolboxitem_class.getfocusabletree_1_method.md) | | See IFocusableNode.getFocusableTree. |\n| [getId()](./blockly.toolboxitem_class.getid_1_method.md) | | Gets a unique identifier for this toolbox item. |\n| [getParent()](./blockly.toolboxitem_class.getparent_1_method.md) | | Gets the parent if the toolbox item is nested. |\n| [init()](./blockly.toolboxitem_class.init_1_method.md) | | Initializes the toolbox item. This includes creating the DOM and updating the state of any items based on the info object. |\n| [isCollapsible()](./blockly.toolboxitem_class.iscollapsible_1_method.md) | | Whether the toolbox item is collapsible. |\n| [isSelectable()](./blockly.toolboxitem_class.isselectable_1_method.md) | | Whether the toolbox item is selectable. |\n| [onNodeBlur()](./blockly.toolboxitem_class.onnodeblur_1_method.md) | | See IFocusableNode.onNodeBlur. |\n| [onNodeFocus()](./blockly.toolboxitem_class.onnodefocus_1_method.md) | | See IFocusableNode.onNodeFocus. |\n| [setVisible_(_isVisible)](./blockly.toolboxitem_class.setvisible__1_method.md) | | Sets whether the category is visible or not. For a category to be visible its parent category must also be expanded. |"]]