Class: ContinuousToolbox
Defined in: plugins/continuous-toolbox/src/ContinuousToolbox.ts:18
Class for continuous toolbox.
Extends
Toolbox
Properties index
| Property | Description |
|---|---|
| boundEvents_ | Array holding info needed to unbind event handlers. Used for disposing. Ex: [[node, name, func], [node, name, func]]. |
| contents | Map from ID to the corresponding toolbox item. |
| contentsDiv_ | The HTML container for the contents of a toolbox. |
| height_ | The height of the toolbox. |
| HtmlDiv | The HTML container for the toolbox. |
| id | The 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
| Method | Description |
|---|---|
| addToolboxItem_ | Adds an item to the toolbox. |
| attachEvents_ | Adds event listeners to the toolbox container div. |
| autoHide | Hides the component. Called in WorkspaceSvg.hideChaff. |
| canBeFocused | See IFocusableNode.canBeFocused. |
| clearSelection | Unhighlights any previously selected item. |
| convertToolboxItemToFlyoutItems | Converts 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. |
| dispose | Disposes of this toolbox. |
| getClientRect | Returns the bounding rectangle of the drag target/deletion area in pixels relative to the viewport. |
| getFlyout | Returns the continuous toolbox's flyout. |
| getFocusableElement | See IFocusableNode.getFocusableElement. |
| getFocusableTree | See IFocusableNode.getFocusableTree. |
| getHeight | Gets the height of the toolbox. |
| getNavigator | Returns the Navigator object responsible for handling keyboard navigation inside this toolbox. |
| getNestedTrees | See IFocusableTree.getNestedTrees. |
| getPreviouslySelectedItem | Gets the previously selected item. |
| getRestoredFocusableNode | See IFocusableTree.getRestoredFocusableNode. |
| getRootFocusableNode | See IFocusableTree.getRootFocusableNode. |
| getSelectedItem | Gets the selected item. |
| getToolboxItemById | Gets the toolbox item with the given ID. |
| getToolboxItems | Gets the items in the toolbox. |
| getWidth | Gets the width of the toolbox. |
| getWorkspace | Gets the workspace for the toolbox. |
| init | Initializes the continuous toolbox. |
| isHorizontal | Gets whether or not the toolbox is horizontal. |
| lookUpFocusableNode | See IFocusableTree.lookUpFocusableNode. |
| onClick_ | Handles on click events for when the toolbox or toolbox items are clicked. |
| onDragEnter | Handles when a cursor with a block or bubble enters this drag target. |
| onDragExit | Handles when a cursor with a block or bubble exits this drag target. |
| onDragOver | Handles when a cursor with a block or bubble is dragged over this drag target. |
| onDrop | Handles when a block or bubble is dropped on this component. Should not handle delete here. |
| onKeyDown_ | Handles key down events for the toolbox. |
| onNodeBlur | See IFocusableNode.onNodeBlur. |
| onNodeFocus | See IFocusableNode.onNodeFocus. |
| onShortcut | Handles the given keyboard shortcut. |
| onTreeBlur | See IFocusableTree.onTreeBlur. |
| onTreeFocus | See IFocusableTree.onTreeFocus. |
| position | Positions the toolbox based on whether it is a horizontal toolbox and whether the workspace is in rtl. |
| refreshSelection | Updates 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. |
| selectItemByPosition | Selects the toolbox item by its position in the list of toolbox items. |
| setSelectedItem | Sets the given item as selected. No-op if the item is not selectable. |
| setVisible | Shows or hides the toolbox. |
| shouldDeselectItem_ | Returns whether or not the toolbox should deselect the old category. |
| shouldPreventMove | 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. |
| 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. |
| wouldDelete | 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. |
Constructors
Constructor
new ContinuousToolbox(workspace): ContinuousToolbox;
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | WorkspaceSvg | The 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
| Parameter | Type | Description |
|---|---|---|
toolboxItem | IToolboxItem | The 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
| Parameter | Type | Description |
|---|---|---|
container | HTMLDivElement | The HTML container for the toolbox. |
contentsContainer | HTMLDivElement | The 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
| Parameter | Type | Description |
|---|---|---|
onlyClosePopups | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
toolboxItem | IToolboxItem | The 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
| Parameter | Type | Description |
|---|---|---|
workspace | WorkspaceSvg | The 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
| Parameter | Type | Description |
|---|---|---|
item | ISelectableToolboxItem | The 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
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
| Parameter | Type |
|---|---|
previousNode | IFocusableNode | 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
| Parameter | Type | Description |
|---|---|---|
id | string | The 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
| Parameter | Type |
|---|---|
id | string |
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
| Parameter | Type | Description |
|---|---|---|
e | PointerEvent | Click 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
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The 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
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The 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
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The 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
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The 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
| Parameter | Type | Description |
|---|---|---|
e | KeyboardEvent | The 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
| Parameter | Type | Description |
|---|---|---|
_shortcut | KeyboardShortcut | The 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
| Parameter | Type |
|---|---|
nextTree | IFocusableTree | null |
Returns
void
Inherited from
Blockly.Toolbox.onTreeBlur
onTreeFocus()
onTreeFocus(node, _previousTree): void;
See IFocusableTree.onTreeFocus.
Parameters
| Parameter | Type |
|---|---|
node | IFocusableNode |
_previousTree | IFocusableTree | 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
| Parameter | Type | Description |
|---|---|---|
toolboxDef | ToolboxItemInfo[] | 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
| Parameter | Type | Description |
|---|---|---|
oldItem | ISelectableToolboxItem | null | The previously selected toolbox item. |
newItem | ISelectableToolboxItem | The 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
| Parameter | Type | Description |
|---|---|---|
position | number | The 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
| Parameter | Type | Description |
|---|---|---|
newItem | IToolboxItem | null | The toolbox item to select. |
Returns
void
Inherited from
Blockly.Toolbox.setSelectedItem
setVisible()
setVisible(isVisible): void;
Shows or hides the toolbox.
Parameters
| Parameter | Type | Description |
|---|---|---|
isVisible | boolean | True 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
| Parameter | Type | Description |
|---|---|---|
oldItem | ISelectableToolboxItem | null | The previously selected toolbox category. |
newItem | ISelectableToolboxItem | null | The 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
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The 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
| Parameter | Type | Description |
|---|---|---|
oldItem | ISelectableToolboxItem | null | The previously selected toolbox item. |
newItem | ISelectableToolboxItem | null | The 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
| Parameter | Type | Description |
|---|---|---|
addStyle | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
oldItem | ISelectableToolboxItem | null | The previously selected toolbox category. |
newItem | ISelectableToolboxItem | null | The newly selected toolbox category. |
Returns
void
Overrides
Blockly.Toolbox.updateFlyout_
updateWouldDelete_()
protected updateWouldDelete_(wouldDelete): void;
Updates the internal wouldDelete_ state.
Parameters
| Parameter | Type | Description |
|---|---|---|
wouldDelete | boolean | The 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
| Parameter | Type | Description |
|---|---|---|
element | IDraggable | The 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