Interface: IToolbox
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:19
Interface for a toolbox.
Extends
Methods index
| Method | Description |
|---|---|
| getRootFocusableNode | Returns the top-level focusable node of the tree. |
| getRestoredFocusableNode | Returns the IFocusableNode of this tree that should receive active focus when the tree itself has focus returned to it. |
| getNestedTrees | Returns all directly nested trees under this tree. |
| lookUpFocusableNode | Returns the IFocusableNode corresponding to the specified element ID, or null if there's no exact node within this tree with that ID or if the ID corresponds to the root of the tree. |
| onTreeFocus | Called when a node of this tree has received active focus. |
| onTreeBlur | Called when the previously actively focused node of this tree is now passively focused and there is no other active node of this tree taking its place. |
| getNavigator | Returns a Navigator instance to be used to determine the navigation order between IFocusableNodes contained within this IFocusableTree. Generally this can just be an instance of Navigator, but trees may choose to return a subclass to customize navigation behavior within their context. |
| init | Initializes the toolbox. |
| render | Fills the toolbox with new toolbox items and removes any old contents. |
| getWidth | Gets the width of the toolbox. |
| getHeight | Gets the height of the toolbox. |
| getFlyout | Gets the toolbox flyout. |
| getWorkspace | Gets the workspace for the toolbox. |
| isHorizontal | Gets whether or not the toolbox is horizontal. |
| position | Positions the toolbox based on whether it is a horizontal toolbox and whether the workspace is in rtl. |
| handleToolboxItemResize | Handles resizing the toolbox when a toolbox item resizes. |
| clearSelection | Unhighlights any previously selected item. |
| refreshTheme | Updates the category colours and background colour of selected categories. |
| refreshSelection | Updates the flyout's content without closing it. Should be used in response to a change in one of the dynamic categories, such as variables or procedures. |
| setVisible | Sets the visibility of the toolbox. |
| selectItemByPosition | Selects the toolbox item by its position in the list of toolbox items. |
| getSelectedItem | Gets the selected item. |
| setSelectedItem | Sets the selected item. |
| dispose | Disposes of this toolbox. |
| getToolboxItems | Returns a list of items in this toolbox. |
Methods
getRootFocusableNode()
getRootFocusableNode(): IFocusableNode;
Defined in: packages/blockly/core/interfaces/i_focusable_tree.ts:39
Returns the top-level focusable node of the tree.
It's expected that the returned node will be focused in cases where FocusManager wants to focus a tree in a situation where it does not currently have a focused node.
Returns
Inherited from
IFocusableTree.getRootFocusableNode
getRestoredFocusableNode()
getRestoredFocusableNode(previousNode): IFocusableNode | null;
Defined in: packages/blockly/core/interfaces/i_focusable_tree.ts:69
Returns the IFocusableNode of this tree that should receive active focus when the tree itself has focus returned to it.
There are some very important notes to consider about a tree's focus lifecycle when implementing a version of this method that doesn't return null:
- A null previousNode does not guarantee first-time focus state as nodes can be deleted.
- This method is only used when the tree itself is focused, either through tab navigation or via FocusManager.focusTree(). In many cases, the previously focused node will be directly focused instead which will bypass this method.
- The default behavior (i.e. returning null here) involves either restoring the previous node (previousNode) or focusing the tree's root.
- The provided node may sometimes no longer be valid, such as in the case an attempt is made to focus a node that has been recently removed from its parent tree. Implementations can check for the validity of the node in order to specialize the node to which focus should fall back.
This method is largely intended to provide tree implementations with the means of specifying a better default node than their root.
Parameters
| Parameter | Type | Description |
|---|---|---|
previousNode | IFocusableNode | null | The node that previously held passive focus for this tree, or null if the tree hasn't yet been focused. |
Returns
IFocusableNode | null
The IFocusableNode that should now receive focus, or null if default behavior should be used, instead.
Inherited from
IFocusableTree.getRestoredFocusableNode
getNestedTrees()
getNestedTrees(): IFocusableTree[];
Defined in: packages/blockly/core/interfaces/i_focusable_tree.ts:82
Returns all directly nested trees under this tree.
Note that the returned list of trees doesn't need to be stable, however all returned trees do need to be registered with FocusManager. Additionally, this must return actual nested trees as omitting a nested tree will affect how focus changes map to a specific node and its tree, potentially leading to user confusion.
Returns
Inherited from
lookUpFocusableNode()
lookUpFocusableNode(id): IFocusableNode | null;
Defined in: packages/blockly/core/interfaces/i_focusable_tree.ts:93
Returns the IFocusableNode corresponding to the specified element ID, or null if there's no exact node within this tree with that ID or if the ID corresponds to the root of the tree.
This will never match against nested trees.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The ID of the node's focusable HTMLElement or SVGElement. |
Returns
IFocusableNode | null
Inherited from
IFocusableTree.lookUpFocusableNode
onTreeFocus()
onTreeFocus(node, previousTree): void;
Defined in: packages/blockly/core/interfaces/i_focusable_tree.ts:112
Called when a node of this tree has received active focus.
Note that a null previousTree does not necessarily indicate that this is the first time Blockly is receiving focus. In fact, few assumptions can be made about previous focus state as a previous null tree simply indicates that Blockly did not hold active focus prior to this tree becoming focused (which can happen due to focus exiting the Blockly injection div, or for other cases like ephemeral focus).
See IFocusableNode.onNodeFocus() as implementations have the same restrictions as with that method.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | IFocusableNode | The node receiving active focus. |
previousTree | IFocusableTree | null | The previous tree that held active focus, or null if none. |
Returns
void
Inherited from
onTreeBlur()
onTreeBlur(nextTree): void;
Defined in: packages/blockly/core/interfaces/i_focusable_tree.ts:125
Called when the previously actively focused node of this tree is now passively focused and there is no other active node of this tree taking its place.
This has the same implementation restrictions and considerations as onTreeFocus().
Parameters
| Parameter | Type | Description |
|---|---|---|
nextTree | IFocusableTree | null | The next tree receiving active focus, or null if none (such as in the case that Blockly is entirely losing DOM focus). |
Returns
void
Inherited from
getNavigator()
getNavigator(): Navigator;
Defined in: packages/blockly/core/interfaces/i_focusable_tree.ts:133
Returns a Navigator instance to be used to determine the navigation order between IFocusableNodes contained within this IFocusableTree. Generally this can just be an instance of Navigator, but trees may choose to return a subclass to customize navigation behavior within their context.
Returns
Inherited from
init()
init(): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:21
Initializes the toolbox.
Returns
void
render()
render(toolboxDef): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:28
Fills the toolbox with new toolbox items and removes any old contents.
Parameters
| Parameter | Type | Description |
|---|---|---|
toolboxDef | ToolboxInfo | Object holding information for creating a toolbox. |
Returns
void
getWidth()
getWidth(): number;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:35
Gets the width of the toolbox.
Returns
number
The width of the toolbox.
getHeight()
getHeight(): number;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:42
Gets the height of the toolbox.
Returns
number
The height of the toolbox.
getFlyout()
getFlyout(): IFlyout | null;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:49
Gets the toolbox flyout.
Returns
IFlyout | null
The toolbox flyout.
getWorkspace()
getWorkspace(): WorkspaceSvg;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:56
Gets the workspace for the toolbox.
Returns
The parent workspace for the toolbox.
isHorizontal()
isHorizontal(): boolean;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:64
Gets whether or not the toolbox is horizontal.
Returns
boolean
True if the toolbox is horizontal, false if the toolbox is vertical.
position()
position(): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:70
Positions the toolbox based on whether it is a horizontal toolbox and whether the workspace is in rtl.
Returns
void
handleToolboxItemResize()
handleToolboxItemResize(): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:73
Handles resizing the toolbox when a toolbox item resizes.
Returns
void
clearSelection()
clearSelection(): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:76
Unhighlights any previously selected item.
Returns
void
refreshTheme()
refreshTheme(): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:81
Updates the category colours and background colour of selected categories.
Returns
void
refreshSelection()
refreshSelection(): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:88
Updates the flyout's content without closing it. Should be used in response to a change in one of the dynamic categories, such as variables or procedures.
Returns
void
setVisible()
setVisible(isVisible): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:95
Sets the visibility of the toolbox.
Parameters
| Parameter | Type | Description |
|---|---|---|
isVisible | boolean | True if toolbox should be visible. |
Returns
void
selectItemByPosition()
selectItemByPosition(position): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:102
Selects the toolbox item by its position in the list of toolbox items.
Parameters
| Parameter | Type | Description |
|---|---|---|
position | number | The position of the item to select. |
Returns
void
getSelectedItem()
getSelectedItem(): IToolboxItem | null;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:109
Gets the selected item.
Returns
IToolboxItem | null
The selected item, or null if no item is currently selected.
setSelectedItem()
setSelectedItem(item): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:117
Sets the selected item.
Parameters
| Parameter | Type | Description |
|---|---|---|
item | IToolboxItem | null | The toolbox item to select, or null to remove the current selection. |
Returns
void
dispose()
dispose(): void;
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:120
Disposes of this toolbox.
Returns
void
getToolboxItems()
getToolboxItems(): IToolboxItem[];
Defined in: packages/blockly/core/interfaces/i_toolbox.ts:125
Returns a list of items in this toolbox.