Skip to main content

Class: ContinuousToolbox

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:18

Class for continuous toolbox.

Extends​

  • Toolbox

Properties index​

PropertyDescription
boundEvents_Array holding info needed to unbind event handlers. Used for disposing. Ex: [[node, name, func], [node, name, func]].
contentsMap from ID to the corresponding toolbox item.
contentsDiv_The HTML container for the contents of a toolbox.
height_The height of the toolbox.
HtmlDivThe HTML container for the toolbox.
idThe unique ID for this component that is used to register with the ComponentManager.
isVisible_Whether the Toolbox is visible.
previouslySelectedItem_The previously selected item.
RTL-
selectedItem_The currently selected item.
toolboxDef_-
toolboxPosition-
width_The width of the toolbox.
workspace_The workspace this toolbox is on.
wouldDelete_Whether the last block or bubble dragged over this delete area would be deleted if dropped on this component. This property is not updated after the block or bubble is deleted.

Methods index​

MethodDescription
addToolboxItem_Adds an item to the toolbox.
attachEvents_Adds event listeners to the toolbox container div.
autoHideHides the component. Called in WorkspaceSvg.hideChaff.
canBeFocusedSee IFocusableNode.canBeFocused.
clearSelectionUnhighlights any previously selected item.
convertToolboxItemToFlyoutItemsConverts a given toolbox item to an array of flyout items, generally a label followed by the category's blocks.
createContainer_Creates the container div for the toolbox.
createContentsContainer_Creates the container for all the contents in the toolbox.
createDom_Creates the DOM for the toolbox.
createFlyout_Creates the flyout based on the toolbox layout.
deselectItem_Deselects the given item, marks it as unselected, and updates aria state.
disposeDisposes of this toolbox.
getClientRectReturns the bounding rectangle of the drag target/deletion area in pixels relative to the viewport.
getFlyoutReturns the continuous toolbox's flyout.
getFocusableElementSee IFocusableNode.getFocusableElement.
getFocusableTreeSee IFocusableNode.getFocusableTree.
getHeightGets the height of the toolbox.
getNavigatorReturns the Navigator object responsible for handling keyboard navigation inside this toolbox.
getNestedTreesSee IFocusableTree.getNestedTrees.
getPreviouslySelectedItemGets the previously selected item.
getRestoredFocusableNodeSee IFocusableTree.getRestoredFocusableNode.
getRootFocusableNodeSee IFocusableTree.getRootFocusableNode.
getSelectedItemGets the selected item.
getToolboxItemByIdGets the toolbox item with the given ID.
getToolboxItemsGets the items in the toolbox.
getWidthGets the width of the toolbox.
getWorkspaceGets the workspace for the toolbox.
initInitializes the continuous toolbox.
isHorizontalGets whether or not the toolbox is horizontal.
lookUpFocusableNodeSee IFocusableTree.lookUpFocusableNode.
onClick_Handles on click events for when the toolbox or toolbox items are clicked.
onDragEnterHandles when a cursor with a block or bubble enters this drag target.
onDragExitHandles when a cursor with a block or bubble exits this drag target.
onDragOverHandles when a cursor with a block or bubble is dragged over this drag target.
onDropHandles when a block or bubble is dropped on this component. Should not handle delete here.
onKeyDown_Handles key down events for the toolbox.
onNodeBlurSee IFocusableNode.onNodeBlur.
onNodeFocusSee IFocusableNode.onNodeFocus.
onShortcutHandles the given keyboard shortcut.
onTreeBlurSee IFocusableTree.onTreeBlur.
onTreeFocusSee IFocusableTree.onTreeFocus.
positionPositions the toolbox based on whether it is a horizontal toolbox and whether the workspace is in rtl.
refreshSelectionUpdates the flyout's contents if it is visible.
renderContents_Adds all the toolbox items to the toolbox.
selectItem_Selects the given item, marks it selected, and updates aria state.
selectItemByPositionSelects the toolbox item by its position in the list of toolbox items.
setSelectedItemSets the given item as selected. No-op if the item is not selectable.
setVisibleShows or hides the toolbox.
shouldDeselectItem_Returns whether or not the toolbox should deselect the old category.
shouldPreventMoveReturns whether the provided block or bubble should not be moved after being dropped on this component. If true, the element will return to where it was when the drag started.
shouldSelectItem_Decides whether the new item should be selected.
updateCursorDeleteStyle_Adds or removes the CSS style of the cursor over the toolbox based whether the block or bubble over it is expected to be deleted if dropped (using the internal this.wouldDelete_ property).
updateFlyout_Scrolls the flyout to display the newly selected category's contents.
updateWouldDelete_Updates the internal wouldDelete_ state.
wouldDeleteReturns whether the provided block or bubble would be deleted if dropped on this area. This method should check if the element is deletable and is always called before onDragEnter/onDragOver/onDragExit.

Constructors​

Constructor​

new ContinuousToolbox(workspace): ContinuousToolbox;

Parameters​

ParameterTypeDescription
workspaceWorkspaceSvgThe workspace in which to create new blocks.

Returns​

ContinuousToolbox

Inherited from​

Blockly.Toolbox.constructor

Properties​

boundEvents_​

protected boundEvents_: Data[];

Array holding info needed to unbind event handlers. Used for disposing. Ex: [[node, name, func], [node, name, func]].

Inherited from​

Blockly.Toolbox.boundEvents_


contents​

protected contents: Map<string, IToolboxItem>;

Map from ID to the corresponding toolbox item.

Inherited from​

Blockly.Toolbox.contents


contentsDiv_​

protected contentsDiv_: HTMLDivElement | null;

The HTML container for the contents of a toolbox.

Inherited from​

Blockly.Toolbox.contentsDiv_


height_​

protected height_: number;

The height of the toolbox.

Inherited from​

Blockly.Toolbox.height_


HtmlDiv​

HtmlDiv: HTMLDivElement | null;

The HTML container for the toolbox.

Inherited from​

Blockly.Toolbox.HtmlDiv


id​

id: string;

The unique ID for this component that is used to register with the ComponentManager.

Inherited from​

Blockly.Toolbox.id


isVisible_​

protected isVisible_: boolean;

Whether the Toolbox is visible.

Inherited from​

Blockly.Toolbox.isVisible_


previouslySelectedItem_​

protected previouslySelectedItem_: ISelectableToolboxItem | null;

The previously selected item.

Inherited from​

Blockly.Toolbox.previouslySelectedItem_


RTL​

RTL: boolean;

Inherited from​

Blockly.Toolbox.RTL


selectedItem_​

protected selectedItem_: ISelectableToolboxItem | null;

The currently selected item.

Inherited from​

Blockly.Toolbox.selectedItem_


toolboxDef_​

protected toolboxDef_: ToolboxInfo;

Inherited from​

Blockly.Toolbox.toolboxDef_


toolboxPosition​

toolboxPosition: Position;

Inherited from​

Blockly.Toolbox.toolboxPosition


width_​

protected width_: number;

The width of the toolbox.

Inherited from​

Blockly.Toolbox.width_


workspace_​

protected readonly workspace_: WorkspaceSvg;

The workspace this toolbox is on.

Inherited from​

Blockly.Toolbox.workspace_


wouldDelete_​

protected wouldDelete_: boolean;

Whether the last block or bubble dragged over this delete area would be deleted if dropped on this component. This property is not updated after the block or bubble is deleted.

Inherited from​

Blockly.Toolbox.wouldDelete_

Methods​

addToolboxItem_()​

protected addToolboxItem_(toolboxItem): void;

Adds an item to the toolbox.

Parameters​

ParameterTypeDescription
toolboxItemIToolboxItemThe item in the toolbox.

Returns​

void

Inherited from​

Blockly.Toolbox.addToolboxItem_


attachEvents_()​

protected attachEvents_(container, contentsContainer): void;

Adds event listeners to the toolbox container div.

Parameters​

ParameterTypeDescription
containerHTMLDivElementThe HTML container for the toolbox.
contentsContainerHTMLDivElementThe HTML container for the contents of the toolbox.

Returns​

void

Inherited from​

Blockly.Toolbox.attachEvents_


autoHide()​

autoHide(onlyClosePopups): void;

Hides the component. Called in WorkspaceSvg.hideChaff.

Parameters​

ParameterTypeDescription
onlyClosePopupsbooleanWhether only popups should be closed. Flyouts should not be closed if this is true.

Returns​

void

Inherited from​

Blockly.Toolbox.autoHide


canBeFocused()​

canBeFocused(): boolean;

See IFocusableNode.canBeFocused.

Returns​

boolean

Inherited from​

Blockly.Toolbox.canBeFocused


clearSelection()​

clearSelection(): void;

Unhighlights any previously selected item.

Returns​

void

Inherited from​

Blockly.Toolbox.clearSelection


convertToolboxItemToFlyoutItems()​

protected convertToolboxItemToFlyoutItems(toolboxItem): FlyoutItemInfoArray;

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:78

Converts a given toolbox item to an array of flyout items, generally a label followed by the category's blocks.

Parameters​

ParameterTypeDescription
toolboxItemIToolboxItemThe toolbox item/category to convert.

Returns​

FlyoutItemInfoArray

An array of flyout items contained in the given toolbox item.


createContainer_()​

protected createContainer_(): HTMLDivElement;

Creates the container div for the toolbox.

Returns​

HTMLDivElement

The HTML container for the toolbox.

Inherited from​

Blockly.Toolbox.createContainer_


createContentsContainer_()​

protected createContentsContainer_(): HTMLDivElement;

Creates the container for all the contents in the toolbox.

Returns​

HTMLDivElement

The HTML container for the toolbox contents.

Inherited from​

Blockly.Toolbox.createContentsContainer_


createDom_()​

protected createDom_(workspace): HTMLDivElement;

Creates the DOM for the toolbox.

Parameters​

ParameterTypeDescription
workspaceWorkspaceSvgThe workspace this toolbox is on.

Returns​

HTMLDivElement

The HTML container for the toolbox.

Inherited from​

Blockly.Toolbox.createDom_


createFlyout_()​

protected createFlyout_(): IFlyout;

Creates the flyout based on the toolbox layout.

Returns​

IFlyout

The flyout for the toolbox.

Throws​

If missing a require for Blockly.HorizontalFlyout, Blockly.VerticalFlyout, and no flyout plugin is specified.

Inherited from​

Blockly.Toolbox.createFlyout_


deselectItem_()​

protected deselectItem_(item): void;

Deselects the given item, marks it as unselected, and updates aria state.

Parameters​

ParameterTypeDescription
itemISelectableToolboxItemThe previously selected toolbox item which should be deselected.

Returns​

void

Inherited from​

Blockly.Toolbox.deselectItem_


dispose()​

dispose(): void;

Disposes of this toolbox.

Returns​

void

Inherited from​

Blockly.Toolbox.dispose


getClientRect()​

getClientRect(): Rect | null;

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:194

Returns the bounding rectangle of the drag target/deletion area in pixels relative to the viewport.

Returns​

Rect | null

The toolbox's bounding box. Null if drag target area should be ignored.

Overrides​

Blockly.Toolbox.getClientRect


getFlyout()​

getFlyout(): ContinuousFlyout;

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:57

Returns the continuous toolbox's flyout.

Returns​

ContinuousFlyout

The toolbox's flyout.

Overrides​

Blockly.Toolbox.getFlyout


getFocusableElement()​

getFocusableElement(): HTMLElement | SVGElement;

See IFocusableNode.getFocusableElement.

Returns​

HTMLElement | SVGElement

Inherited from​

Blockly.Toolbox.getFocusableElement


getFocusableTree()​

getFocusableTree(): IFocusableTree;

See IFocusableNode.getFocusableTree.

Returns​

IFocusableTree

Inherited from​

Blockly.Toolbox.getFocusableTree


getHeight()​

getHeight(): number;

Gets the height of the toolbox.

Returns​

number

The width of the toolbox.

Inherited from​

Blockly.Toolbox.getHeight


getNavigator()​

getNavigator(): ToolboxNavigator;

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:207

Returns the Navigator object responsible for handling keyboard navigation inside this toolbox.

Returns​

ToolboxNavigator

Overrides​

Blockly.Toolbox.getNavigator


getNestedTrees()​

getNestedTrees(): IFocusableTree[];

See IFocusableTree.getNestedTrees.

Returns​

IFocusableTree[]

Inherited from​

Blockly.Toolbox.getNestedTrees


getPreviouslySelectedItem()​

getPreviouslySelectedItem(): ISelectableToolboxItem | null;

Gets the previously selected item.

Returns​

ISelectableToolboxItem | null

The previously selected item, or null if no item was previously selected.

Inherited from​

Blockly.Toolbox.getPreviouslySelectedItem


getRestoredFocusableNode()​

getRestoredFocusableNode(previousNode): IFocusableNode | null;

See IFocusableTree.getRestoredFocusableNode.

Parameters​

ParameterType
previousNodeIFocusableNode | null

Returns​

IFocusableNode | null

Inherited from​

Blockly.Toolbox.getRestoredFocusableNode


getRootFocusableNode()​

getRootFocusableNode(): IFocusableNode;

See IFocusableTree.getRootFocusableNode.

Returns​

IFocusableNode

Inherited from​

Blockly.Toolbox.getRootFocusableNode


getSelectedItem()​

getSelectedItem(): ISelectableToolboxItem | null;

Gets the selected item.

Returns​

ISelectableToolboxItem | null

The selected item, or null if no item is currently selected.

Inherited from​

Blockly.Toolbox.getSelectedItem


getToolboxItemById()​

getToolboxItemById(id): IToolboxItem | null;

Gets the toolbox item with the given ID.

Parameters​

ParameterTypeDescription
idstringThe ID of the toolbox item.

Returns​

IToolboxItem | null

The toolbox item with the given ID, or null if no item exists.

Inherited from​

Blockly.Toolbox.getToolboxItemById


getToolboxItems()​

getToolboxItems(): IToolboxItem[];

Gets the items in the toolbox.

Returns​

IToolboxItem[]

The list of items in the toolbox.

Inherited from​

Blockly.Toolbox.getToolboxItems


getWidth()​

getWidth(): number;

Gets the width of the toolbox.

Returns​

number

The width of the toolbox.

Inherited from​

Blockly.Toolbox.getWidth


getWorkspace()​

getWorkspace(): WorkspaceSvg;

Gets the workspace for the toolbox.

Returns​

WorkspaceSvg

The parent workspace for the toolbox.

Inherited from​

Blockly.Toolbox.getWorkspace


init()​

init(): void;

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:34

Initializes the continuous toolbox.

Returns​

void

Overrides​

Blockly.Toolbox.init


isHorizontal()​

isHorizontal(): boolean;

Gets whether or not the toolbox is horizontal.

Returns​

boolean

True if the toolbox is horizontal, false if the toolbox is vertical.

Inherited from​

Blockly.Toolbox.isHorizontal


lookUpFocusableNode()​

lookUpFocusableNode(id): IFocusableNode | null;

See IFocusableTree.lookUpFocusableNode.

Parameters​

ParameterType
idstring

Returns​

IFocusableNode | null

Inherited from​

Blockly.Toolbox.lookUpFocusableNode


onClick_()​

protected onClick_(e): void;

Handles on click events for when the toolbox or toolbox items are clicked.

Parameters​

ParameterTypeDescription
ePointerEventClick event to handle.

Returns​

void

Inherited from​

Blockly.Toolbox.onClick_


onDragEnter()​

onDragEnter(_dragElement): void;

Handles when a cursor with a block or bubble enters this drag target.

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

void

Inherited from​

Blockly.Toolbox.onDragEnter


onDragExit()​

onDragExit(_dragElement): void;

Handles when a cursor with a block or bubble exits this drag target.

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

void

Inherited from​

Blockly.Toolbox.onDragExit


onDragOver()​

onDragOver(_dragElement): void;

Handles when a cursor with a block or bubble is dragged over this drag target.

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

void

Inherited from​

Blockly.Toolbox.onDragOver


onDrop()​

onDrop(_dragElement): void;

Handles when a block or bubble is dropped on this component. Should not handle delete here.

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

void

Inherited from​

Blockly.Toolbox.onDrop


onKeyDown_()​

protected onKeyDown_(e): void;

Handles key down events for the toolbox.

Parameters​

ParameterTypeDescription
eKeyboardEventThe key down event.

Returns​

void

Inherited from​

Blockly.Toolbox.onKeyDown_


onNodeBlur()​

onNodeBlur(): void;

See IFocusableNode.onNodeBlur.

Returns​

void

Inherited from​

Blockly.Toolbox.onNodeBlur


onNodeFocus()​

onNodeFocus(): void;

See IFocusableNode.onNodeFocus.

Returns​

void

Inherited from​

Blockly.Toolbox.onNodeFocus


onShortcut()​

onShortcut(_shortcut): boolean;

Handles the given keyboard shortcut.

Parameters​

ParameterTypeDescription
_shortcutKeyboardShortcutThe shortcut to be handled.

Returns​

boolean

True if the shortcut has been handled, false otherwise.

Inherited from​

Blockly.Toolbox.onShortcut


onTreeBlur()​

onTreeBlur(nextTree): void;

See IFocusableTree.onTreeBlur.

Parameters​

ParameterType
nextTreeIFocusableTree | null

Returns​

void

Inherited from​

Blockly.Toolbox.onTreeBlur


onTreeFocus()​

onTreeFocus(node, _previousTree): void;

See IFocusableTree.onTreeFocus.

Parameters​

ParameterType
nodeIFocusableNode
_previousTreeIFocusableTree | null

Returns​

void

Inherited from​

Blockly.Toolbox.onTreeFocus


position()​

position(): void;

Positions the toolbox based on whether it is a horizontal toolbox and whether the workspace is in rtl.

Returns​

void

Inherited from​

Blockly.Toolbox.position


refreshSelection()​

refreshSelection(): void;

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:99

Updates the flyout's contents if it is visible.

Returns​

void

Overrides​

Blockly.Toolbox.refreshSelection


renderContents_()​

protected renderContents_(toolboxDef): void;

Adds all the toolbox items to the toolbox.

Parameters​

ParameterTypeDescription
toolboxDefToolboxItemInfo[]Array holding objects containing information on the contents of the toolbox.

Returns​

void

Inherited from​

Blockly.Toolbox.renderContents_


selectItem_()​

protected selectItem_(oldItem, newItem): void;

Selects the given item, marks it selected, and updates aria state.

Parameters​

ParameterTypeDescription
oldItemISelectableToolboxItem | nullThe previously selected toolbox item.
newItemISelectableToolboxItemThe newly selected toolbox item.

Returns​

void

Inherited from​

Blockly.Toolbox.selectItem_


selectItemByPosition()​

selectItemByPosition(position): void;

Selects the toolbox item by its position in the list of toolbox items.

Parameters​

ParameterTypeDescription
positionnumberThe position of the item to select.

Returns​

void

Inherited from​

Blockly.Toolbox.selectItemByPosition


setSelectedItem()​

setSelectedItem(newItem): void;

Sets the given item as selected. No-op if the item is not selectable.

Parameters​

ParameterTypeDescription
newItemIToolboxItem | nullThe toolbox item to select.

Returns​

void

Inherited from​

Blockly.Toolbox.setSelectedItem


setVisible()​

setVisible(isVisible): void;

Shows or hides the toolbox.

Parameters​

ParameterTypeDescription
isVisiblebooleanTrue if toolbox should be visible.

Returns​

void

Inherited from​

Blockly.Toolbox.setVisible


shouldDeselectItem_()​

shouldDeselectItem_(oldItem, newItem): boolean;

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:138

Returns whether or not the toolbox should deselect the old category.

Parameters​

ParameterTypeDescription
oldItemISelectableToolboxItem | nullThe previously selected toolbox category.
newItemISelectableToolboxItem | nullThe newly selected toolbox category.

Returns​

boolean

Overrides​

Blockly.Toolbox.shouldDeselectItem_


shouldPreventMove()​

shouldPreventMove(_dragElement): boolean;

Returns whether the provided block or bubble should not be moved after being dropped on this component. If true, the element will return to where it was when the drag started.

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

boolean

Whether the block or bubble provided should be returned to drag start.

Inherited from​

Blockly.Toolbox.shouldPreventMove


shouldSelectItem_()​

protected shouldSelectItem_(oldItem, newItem): boolean;

Decides whether the new item should be selected.

Parameters​

ParameterTypeDescription
oldItemISelectableToolboxItem | nullThe previously selected toolbox item.
newItemISelectableToolboxItem | nullThe newly selected toolbox item.

Returns​

boolean

True if the new item should be selected, false otherwise.

Inherited from​

Blockly.Toolbox.shouldSelectItem_


updateCursorDeleteStyle_()​

protected updateCursorDeleteStyle_(addStyle): void;

Adds or removes the CSS style of the cursor over the toolbox based whether the block or bubble over it is expected to be deleted if dropped (using the internal this.wouldDelete_ property).

Parameters​

ParameterTypeDescription
addStylebooleanWhether the style should be added or removed.

Returns​

void

Inherited from​

Blockly.Toolbox.updateCursorDeleteStyle_


updateFlyout_()​

updateFlyout_(oldItem, newItem): void;

Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:117

Scrolls the flyout to display the newly selected category's contents.

Parameters​

ParameterTypeDescription
oldItemISelectableToolboxItem | nullThe previously selected toolbox category.
newItemISelectableToolboxItem | nullThe newly selected toolbox category.

Returns​

void

Overrides​

Blockly.Toolbox.updateFlyout_


updateWouldDelete_()​

protected updateWouldDelete_(wouldDelete): void;

Updates the internal wouldDelete_ state.

Parameters​

ParameterTypeDescription
wouldDeletebooleanThe new value for the wouldDelete state.

Returns​

void

Inherited from​

Blockly.Toolbox.updateWouldDelete_


wouldDelete()​

wouldDelete(element): boolean;

Returns whether the provided block or bubble would be deleted if dropped on this area. This method should check if the element is deletable and is always called before onDragEnter/onDragOver/onDragExit.

Parameters​

ParameterTypeDescription
elementIDraggableThe block or bubble currently being dragged.

Returns​

boolean

Whether the element provided would be deleted if dropped on this area.

Inherited from​

Blockly.Toolbox.wouldDelete