Skip to main content

Class: ToolboxItem

Defined in: packages/blockly/core/toolbox/toolbox_item.ts:25

Class for an item in the toolbox.

Extended by

Implements

Properties index

PropertyDescription
id_-
parent_-
level_-
toolboxItemDef_-
workspace_-
parentToolbox_The toolbox this category belongs to.

Methods index

MethodDescription
initInitializes the toolbox item. This includes creating the DOM and updating the state of any items based on the info object.
getDivGets the div for the toolbox item.
getClickTargetGets 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.
getIdGets a unique identifier for this toolbox item.
getParentGets the parent if the toolbox item is nested.
isSelectableWhether the toolbox item is selectable.
isCollapsibleWhether the toolbox item is collapsible.
disposeDispose 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.
getFocusableElementSee IFocusableNode.getFocusableElement.
getFocusableTreeSee IFocusableNode.getFocusableTree.
onNodeFocusSee IFocusableNode.onNodeFocus.
onNodeBlurSee IFocusableNode.onNodeBlur.
canBeFocusedSee IFocusableNode.canBeFocused.
getParentToolboxReturns 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

ParameterTypeDescription
toolboxItemDefToolboxItemInfoThe JSON defining the toolbox item.
parentToolboxIToolboxThe toolbox that holds the toolbox item.
opt_parent?ICollapsibleToolboxItemThe 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

IToolboxItem.init


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

IToolboxItem.getDiv


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

IToolboxItem.getClickTarget


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

IToolboxItem.getId


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

IToolboxItem.getParent


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

IToolboxItem.isSelectable


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

IToolboxItem.isCollapsible


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

IToolboxItem.dispose


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

ParameterTypeDescription
_isVisiblebooleanTrue if category should be visible.

Returns

void

Implementation of

IToolboxItem.setVisible_


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

IFocusableTree

Implementation of

IToolboxItem.getFocusableTree


onNodeFocus()

onNodeFocus(): void;

Defined in: packages/blockly/core/toolbox/toolbox_item.ts:171

See IFocusableNode.onNodeFocus.

Returns

void

Implementation of

IToolboxItem.onNodeFocus


onNodeBlur()

onNodeBlur(): void;

Defined in: packages/blockly/core/toolbox/toolbox_item.ts:181

See IFocusableNode.onNodeBlur.

Returns

void

Implementation of

IToolboxItem.onNodeBlur


canBeFocused()

canBeFocused(): boolean;

Defined in: packages/blockly/core/toolbox/toolbox_item.ts:184

See IFocusableNode.canBeFocused.

Returns

boolean

Implementation of

IToolboxItem.canBeFocused


getParentToolbox()

getParentToolbox(): IToolbox;

Defined in: packages/blockly/core/toolbox/toolbox_item.ts:191

Returns the toolbox this toolbox item belongs to.

Returns

IToolbox

Implementation of

IToolboxItem.getParentToolbox