Class: Toolbox

Constructor

Toolbox

new Toolbox(workspace)

Class for a Toolbox. Creates the toolbox's DOM.

Parameter

workspace

Blockly.WorkspaceSvg

The workspace in which to create new blocks.

Value must not be null.

Implements
Blockly.IBlocklyActionable
Blockly.IDeleteArea
Blockly.IStyleable
Blockly.IToolbox

Class

Properties

config_

non-null Blockly.tree.BaseNode.Config

height

number

Height of the toolbox, which changes only in horizontal layout.

HtmlDiv

Element

HTML container for the Toolbox menu.

HtmlDiv

non-null Element

HtmlDiv

non-null Element

RTL

boolean

Is RTL vs LTR.

toolboxPosition

number

Position of the toolbox and flyout relative to the workspace.

treeSeparatorConfig_

non-null Blockly.tree.BaseNode.Config

width

number

Width of the toolbox, which changes only in vertical layout.

Methods

addStyle

package

addStyle(style)

Adds a style on the toolbox. Usually used to change the cursor.

Parameter

style

string

The name of the class to add.

Implements
Blockly.IStyleable#addStyle

clearSelection

clearSelection()

Unhighlight any previously specified option.

Implements
Blockly.IToolbox#clearSelection

dispose

dispose()

Dispose of this toolbox.

Implements
Blockly.IToolbox#dispose

getClientRect

getClientRect() returns Blockly.utils.Rect

Return the deletion rectangle for this toolbox.

Implements
Blockly.IDeleteArea#getClientRect
Returns

Blockly.utils.Rect Rectangle in which to delete.

getFlyout

getFlyout() returns Blockly.Flyout

Get the toolbox flyout.

Implements
Blockly.IToolbox#getFlyout
Returns

Blockly.Flyout The toolbox flyout.

getHeight

getHeight() returns number

Get the height of the toolbox.

Implements
Blockly.IToolbox#getHeight
Returns

number The width of the toolbox.

getWidth

getWidth() returns number

Get the width of the toolbox.

Implements
Blockly.IToolbox#getWidth
Returns

number The width of the toolbox.

init

init()

Initializes the toolbox.

Implements
Blockly.IToolbox#init
Throws

Error If missing a require for both Blockly.HorizontalFlyout and Blockly.VerticalFlyout.

onBlocklyAction

package

onBlocklyAction(action) returns boolean

Handles the given Blockly action on a toolbox. This is only triggered when keyboard accessibility mode is enabled.

Parameter

action

Blockly.Action

The action to be handled.

Value must not be null.

Implements
Blockly.IBlocklyActionable#onBlocklyAction
Returns

boolean True if the field handled the action, false otherwise.

position

position()

Move the toolbox to the edge.

Implements
Blockly.IToolbox#position

refreshSelection

refreshSelection()

Update the flyout's contents without closing it. Should be used in response to a change in one of the dynamic categories, such as variables or procedures.

Implements
Blockly.IToolbox#refreshSelection

refreshTheme

package

refreshTheme()

Updates the category colours and background colour of selected categories.

Implements
Blockly.IToolbox#refreshTheme

removeStyle

package

removeStyle(style)

Removes a style from the toolbox. Usually used to change the cursor.

Parameter

style

string

The name of the class to remove.

Implements
Blockly.IStyleable#removeStyle

render

package

render(toolboxDef)

Fill the toolbox with categories and blocks.

Parameter

toolboxDef

Array of Blockly.utils.toolbox.Toolbox

Array holding objects containing information on the contents of the toolbox.

Implements
Blockly.IToolbox#render

selectFirstCategory

package

selectFirstCategory()

Select the first toolbox category if no category is selected.

Implements
Blockly.IToolbox#selectFirstCategory

setVisible

setVisible(isVisible)

Toggles the visibility of the toolbox.

Parameter

isVisible

boolean

True if toolbox should be visible.

Implements
Blockly.IToolbox#setVisible