blockly > ToolboxCategory

ToolboxCategory class

Class for a category in a toolbox.

Signature:

export declare class ToolboxCategory extends ToolboxItem implements ISelectableToolboxItem 

Extends: ToolboxItem

Implements: ISelectableToolboxItem

Constructors

Constructor Modifiers Description
(constructor)(categoryDef, parentToolbox, opt_parent) Constructs a new instance of the ToolboxCategory class

Properties

Property Modifiers Type Description
borderWidth static number The width in pixels of the strip of colour next to each category.
colour_ protected string The colour of the category.
cssConfig_ protected CssConfig
defaultBackgroundColour static string The default colour of the category. This is used as the background colour of the category when it is selected.
flyoutItems_ protected string | FlyoutItemInfoArray The flyout items for this category.
htmlDiv_ protected HTMLDivElement | null The HTML container for the category.
iconDom_ protected Element | null The HTML element for the toolbox icon.
isDisabled_ protected boolean True if this category is disabled, false otherwise.
isHidden_ protected boolean True if the category is meant to be hidden, false otherwise.
labelDom_ protected Element | null The HTML element for the toolbox label.
name_ protected string The name that will be displayed on the category.
nestedPadding static number The number of pixels to move the category over at each nested level.
registrationName static string Name used for registering a toolbox category.
rowContents_ protected HTMLDivElement | null The HTML element that holds children elements of the category row.
rowDiv_ protected HTMLDivElement | null The HTML element for the category row.
toolboxItemDef_ CategoryInfo

Methods

Method Modifiers Description
addColourBorder_(colour) protected Add the strip of colour to the toolbox category.
allAncestorsExpanded_() protected Whether all ancestors of a category (parent and parent's parent, etc.) are expanded.
closeIcon_(iconDiv) protected Adds appropriate classes to display a closed icon.
createContainer_() protected Creates the container that holds the row and any subcategories.
createDom_() protected Creates the DOM for the category.
createIconDom_() protected Creates the span that holds the category icon.
createLabelDom_(name) protected Creates the span that holds the category label. This should have an ID for accessibility purposes.
createRowContainer_() protected Creates the parent of the contents container. All clicks will happen on this div.
createRowContentsContainer_() protected Creates the container for the label and icon. This is necessary so we can set all subcategory pointer events to none.
dispose()
getClickTarget() 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.
getColour_(categoryDef) protected Gets either the colour or the style for a category.
getContents() Gets the contents of the category. These are items that are meant to be displayed in the flyout.
getDiv()
getName() Gets the name of the category. Used for emitting events.
getParent()
hide() Hide the category.
init() Initializes the toolbox item. This includes creating the DOM and updating the state of any items based on the info object. Init should be called immediately after the construction of the toolbox item, to ensure that the category contents are properly parsed.
isSelectable()
isVisible() Whether the category is visible. A category is only visible if all of its ancestors are expanded and isHidden_ is false.
makeDefaultCssConfig_() protected Creates an object holding the default classes for a category.
onClick(_e) Handles when the toolbox item is clicked.
openIcon_(iconDiv) protected Adds appropriate classes to display an open icon.
parseCategoryDef_(categoryDef) protected Parses the non-contents parts of the category def.
parseContents_(categoryDef) protected Parses the contents array depending on if the category is a dynamic category, or if its contents are meant to be shown in the flyout.
refreshTheme() Updates the colour for this category.
setDisabled(isDisabled) Sets whether the category is disabled.
setSelected(isSelected) Sets the current category as selected.
setVisible_(isVisible) Sets whether the category is visible or not. For a category to be visible its parent category must also be expanded.
show() Show the category. Category will only appear if its parent category is also expanded.
updateFlyoutContents(contents) Updates the contents to be displayed in the flyout. If the flyout is open when the contents are updated, refreshSelection on the toolbox must also be called.