Class: ToolboxItem
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:25
Class for an item in the toolbox.
Extended by
Implements
Properties index
| Property | Description |
|---|---|
| id_ | - |
| parent_ | - |
| level_ | - |
| toolboxItemDef_ | - |
| workspace_ | - |
| parentToolbox_ | The toolbox this category belongs to. |
Methods index
| Method | Description |
|---|---|
| init | Initializes the toolbox item. This includes creating the DOM and updating the state of any items based on the info object. |
| getDiv | Gets the div for the toolbox item. |
| 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. |
| getId | Gets a unique identifier for this toolbox item. |
| getParent | Gets the parent if the toolbox item is nested. |
| isSelectable | Whether the toolbox item is selectable. |
| isCollapsible | Whether the toolbox item is collapsible. |
| dispose | Dispose of this toolbox item. No-op by default. |
| setVisible_ | Sets whether the category is visible or not. For a category to be visible its parent category must also be expanded. |
| getFocusableElement | See IFocusableNode.getFocusableElement. |
| getFocusableTree | See IFocusableNode.getFocusableTree. |
| onNodeFocus | See IFocusableNode.onNodeFocus. |
| onNodeBlur | See IFocusableNode.onNodeBlur. |
| canBeFocused | See IFocusableNode.canBeFocused. |
| getParentToolbox | Returns the toolbox this toolbox item belongs to. |
Constructors
Constructor
new ToolboxItem(
toolboxItemDef,
parentToolbox,
opt_parent?
): ToolboxItem;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:40
Parameters
| Parameter | Type | Description |
|---|---|---|
toolboxItemDef | ToolboxItemInfo | The JSON defining the toolbox item. |
parentToolbox | IToolbox | The toolbox that holds the toolbox item. |
opt_parent? | ICollapsibleToolboxItem | The parent toolbox item or null if the category does not have a parent. |
Returns
ToolboxItem
Properties
id_
protected id_: string;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:26
parent_
protected parent_:
| ICollapsibleToolboxItem
| null;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:27
level_
protected level_: number;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:28
toolboxItemDef_
protected toolboxItemDef_:
| ToolboxItemInfo
| null;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:29
workspace_
protected workspace_: WorkspaceSvg;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:30
parentToolbox_
protected readonly parentToolbox_: IToolbox;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:32
The toolbox this category belongs to.
Methods
init()
init(): void;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:70
Initializes the toolbox item. This includes creating the DOM and updating the state of any items based on the info object.
Returns
void
Implementation of
getDiv()
getDiv(): Element | null;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:78
Gets the div for the toolbox item.
Returns
Element | null
The div for the toolbox item.
Implementation of
getClickTarget()
getClickTarget(): Element | null;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:91
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.
Returns
Element | null
The HTML element that receives clicks, or null if this item should not receive clicks.
Implementation of
getId()
getId(): string;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:100
Gets a unique identifier for this toolbox item.
Returns
string
The ID for the toolbox item.
Implementation of
getParent()
getParent():
| ICollapsibleToolboxItem
| null;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:110
Gets the parent if the toolbox item is nested.
Returns
| ICollapsibleToolboxItem
| null
The parent toolbox item, or null if this toolbox item is not nested.
Implementation of
isSelectable()
isSelectable(): boolean;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:129
Whether the toolbox item is selectable.
Returns
boolean
True if the toolbox item can be selected.
Implementation of
isCollapsible()
isCollapsible(): boolean;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:138
Whether the toolbox item is collapsible.
Returns
boolean
True if the toolbox item is collapsible.
Implementation of
dispose()
dispose(): void;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:143
Dispose of this toolbox item. No-op by default.
Returns
void
Implementation of
setVisible_()
setVisible_(_isVisible): void;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:151
Sets whether the category is visible or not. For a category to be visible its parent category must also be expanded.
Parameters
| Parameter | Type | Description |
|---|---|---|
_isVisible | boolean | True if category should be visible. |
Returns
void
Implementation of
getFocusableElement()
getFocusableElement(): HTMLElement | SVGElement;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:154
See IFocusableNode.getFocusableElement.
Returns
HTMLElement | SVGElement
Implementation of
IToolboxItem.getFocusableElement
getFocusableTree()
getFocusableTree(): IFocusableTree;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:166
See IFocusableNode.getFocusableTree.
Returns
Implementation of
onNodeFocus()
onNodeFocus(): void;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:171
See IFocusableNode.onNodeFocus.
Returns
void
Implementation of
onNodeBlur()
onNodeBlur(): void;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:181
See IFocusableNode.onNodeBlur.
Returns
void
Implementation of
canBeFocused()
canBeFocused(): boolean;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:184
See IFocusableNode.canBeFocused.
Returns
boolean
Implementation of
getParentToolbox()
getParentToolbox(): IToolbox;
Defined in: packages/blockly/core/toolbox/toolbox_item.ts:191
Returns the toolbox this toolbox item belongs to.