Blockly. CollapsibleToolboxCategory
Constructor
CollapsibleToolboxCategory
new CollapsibleToolboxCategory(categoryDef, toolbox, opt_parent)
Class for a category in a toolbox that can be collapsed.
Parameter |
|
---|---|
categoryDef |
Blockly.utils.toolbox.CategoryInfo The information needed to create a category in the toolbox. Value must not be null. |
toolbox |
The parent toolbox for the category. Value must not be null. |
opt_parent |
Optional Blockly.ICollapsibleToolboxItem The parent category or null if the category does not have a parent. |
- Extends
- Blockly.ToolboxCategory
- Implements
- Blockly.ICollapsibleToolboxItem
Properties
registrationName
string
Name used for registering a collapsible toolbox category.
colour_
unknown
The colour of the category.
- Inherited from
- Blockly.ToolboxCategory#colour_
cssConfig_
unknown
All the css class names that are used to create a category.
- Inherited from
- Blockly.ToolboxCategory#cssConfig_
expanded_
boolean
Whether or not the category should display its subcategories.
flyoutItems_
unknown
The flyout items for this category.
- Inherited from
- Blockly.ToolboxCategory#flyoutItems_
htmlDiv_
non-null Element
iconDom_
unknown
The html element for the toolbox icon.
- Inherited from
- Blockly.ToolboxCategory#iconDom_
id_
unknown
The id for the category.
- Inherited from
- Blockly.ToolboxItem#id_
isDisabled_
unknown
True if this category is disabled, false otherwise.
- Inherited from
- Blockly.ToolboxCategory#isDisabled_
isHidden_
unknown
True if the category is meant to be hidden, false otherwise.
- Inherited from
- Blockly.ToolboxCategory#isHidden_
labelDom_
unknown
The html element for the toolbox label.
- Inherited from
- Blockly.ToolboxCategory#labelDom_
level_
unknown
The level that the category is nested at.
- Inherited from
- Blockly.ToolboxItem#level_
name_
unknown
The name that will be displayed on the category.
- Inherited from
- Blockly.ToolboxCategory#name_
parent_
unknown
The parent of the category.
- Inherited from
- Blockly.ToolboxItem#parent_
parentToolbox_
unknown
The toolbox this category belongs to.
- Inherited from
- Blockly.ToolboxItem#parentToolbox_
rowContents_
unknown
The html element that holds children elements of the category row.
- Inherited from
- Blockly.ToolboxCategory#rowContents_
rowDiv_
unknown
The html element for the category row.
- Inherited from
- Blockly.ToolboxCategory#rowDiv_
subcategoriesDiv_
nullable Element
Container for any child categories.
toolboxItemDef_
unknown
- Inherited from
- Blockly.ToolboxCategory#toolboxItemDef_
toolboxItems_
non-null Array of non-null Blockly.ToolboxItem
The child toolbox items for this category.
workspace_
unknown
The workspace of the parent toolbox.
- Inherited from
- Blockly.ToolboxItem#workspace_
Methods
addColourBorder_
addColourBorder_(colour)
Add the strip of colour to the toolbox category.
Parameter |
|
---|---|
colour |
The category colour. |
- Inherited from
- Blockly.ToolboxCategory#addColourBorder_
allAncestorsExpanded_
allAncestorsExpanded_() returns boolean
Whether all ancestors of a category (parent and parent's parent, etc.) are expanded.
- Inherited from
- Blockly.ToolboxCategory#allAncestorsExpanded_
- Returns
-
True only if every ancestor is expanded
closeIcon_
closeIcon_(iconDiv)
Adds appropriate classes to display a closed icon.
Parameter |
|
---|---|
iconDiv |
The div that holds the icon. Value may be null. |
- Inherited from
- Blockly.ToolboxCategory#closeIcon_
createContainer_
createContainer_() returns Element
Creates the container that holds the row and any subcategories.
- Inherited from
- Blockly.ToolboxCategory#createContainer_
- Returns
-
The div that holds the icon and the label.
createDom_
createDom_() returns Element
Creates the dom for the category.
- Inherited from
- Blockly.CollapsibleToolboxCategory#createDom_
- Returns
-
The parent element for the category.
createIconDom_
createIconDom_() returns Element
Creates the span that holds the category icon.
- Inherited from
- Blockly.CollapsibleToolboxCategory#createIconDom_
- Returns
-
The span that holds the category icon.
createLabelDom_
createLabelDom_(name) returns Element
Creates the span that holds the category label. This should have an id for accessibility purposes.
Parameter |
|
---|---|
name |
The name of the category. |
- Inherited from
- Blockly.ToolboxCategory#createLabelDom_
- Returns
-
The span that holds the category label.
createRowContainer_
createRowContainer_() returns Element
Creates the parent of the contents container. All clicks will happen on this div.
- Inherited from
- Blockly.ToolboxCategory#createRowContainer_
- Returns
-
The div that holds the contents container.
createRowContentsContainer_
createRowContentsContainer_() returns Element
Creates the container for the label and icon. This is necessary so we can set all subcategory pointer events to none.
- Inherited from
- Blockly.ToolboxCategory#createRowContentsContainer_
- Returns
-
The div that holds the icon and the label.
createSubCategoriesDom_
createSubCategoriesDom_(subcategories) returns Element
Create the dom for all subcategories.
Parameter |
|
---|---|
subcategories |
Array of non-null Blockly.ToolboxItem The subcategories. Value must not be null. |
- Returns
-
non-null Element
The div holding all the subcategories.
getChildToolboxItems
getChildToolboxItems() returns Array of non-null Blockly.IToolboxItem
Gets any children toolbox items. (ex. Gets the subcategories)
- Implements
- Blockly.ICollapsibleToolboxItem#getChildToolboxItems
- Returns
-
non-null Array of non-null Blockly.IToolboxItem
The child toolbox items.
getClickTarget
getClickTarget() returns Element
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.
- Inherited from
- Blockly.ToolboxCategory#getClickTarget
- Implements
- Blockly.ISelectableToolboxItem#getClickTarget
- Blockly.ICollapsibleToolboxItem#getClickTarget
- Returns
-
The html element that receives clicks.
getColour_
getColour_(categoryDef) returns string
Gets either the colour or the style for a category.
Parameter |
|
---|---|
categoryDef |
The object holding information on the category. Value must not be null. |
- Inherited from
- Blockly.ToolboxCategory#getColour_
- Returns
-
The hex colour for the category.
getContents
getContents() returns (Blockly.utils.toolbox.FlyoutItemInfoArray or string)
Gets the contents of the category. These are items that are meant to be displayed in the flyout.
- Inherited from
- Blockly.ToolboxCategory#getContents
- Implements
- Blockly.ISelectableToolboxItem#getContents
- Blockly.ICollapsibleToolboxItem#getContents
- Returns
-
The definition of items to be displayed in the flyout.
getId
getId() returns string
Gets a unique identifier for this toolbox item.
- Inherited from
- Blockly.ToolboxItem#getId
- Implements
- Blockly.IToolboxItem#getId
- Blockly.ICollapsibleToolboxItem#getId
- Returns
-
The id for the toolbox item.
getLevel
getLevel() returns number
Gets the nested level of the category.
- Inherited from
- Blockly.ToolboxItem#getLevel
- Implements
- Blockly.IToolboxItem#getLevel
- Blockly.ICollapsibleToolboxItem#getLevel
- Returns
-
The nested level of the category.
getName
getName() returns string
Gets the name of the category. Used for emitting events.
- Inherited from
- Blockly.ToolboxCategory#getName
- Implements
- Blockly.ISelectableToolboxItem#getName
- Blockly.ICollapsibleToolboxItem#getName
- Returns
-
The name of the toolbox item.
hide
hide()
Hide the category.
- Inherited from
- Blockly.ToolboxCategory#hide
isCollapsible
isCollapsible() returns boolean
Whether the toolbox item is collapsible.
- Inherited from
- Blockly.ToolboxItem#isCollapsible
- Implements
- Blockly.IToolboxItem#isCollapsible
- Blockly.ICollapsibleToolboxItem#isCollapsible
- Returns
-
True if the toolbox item is collapsible.
isExpanded
isExpanded() returns boolean
Whether the category is expanded to show its child subcategories.
- Implements
- Blockly.ICollapsibleToolboxItem#isExpanded
- Returns
-
boolean
True if the toolbox item shows its children, false if it is collapsed.
isVisible
isVisible() returns boolean
Whether the category is visible. A category is only visible if all of its ancestors are expanded and isHidden_ is false.
- Inherited from
- Blockly.ToolboxCategory#isVisible
- Returns
-
True if the category is visible, false otherwise.
makeDefaultCssConfig_
makeDefaultCssConfig_() returns Blockly.ToolboxCategory.CssConfig
Creates an object holding the default classes for a category.
- Inherited from
- Blockly.CollapsibleToolboxCategory#makeDefaultCssConfig_
- Returns
-
The configuration object holding all the CSS classes for a category.
onClick
onClick(_e)
Handles when the toolbox item is clicked.
Parameter |
|
---|---|
_e |
Click event to handle. Value must not be null. |
- Inherited from
- Blockly.CollapsibleToolboxCategory#onClick
- Implements
- Blockly.ISelectableToolboxItem#onClick
- Blockly.ICollapsibleToolboxItem#onClick
openIcon_
openIcon_(iconDiv)
Adds appropriate classes to display an open icon.
Parameter |
|
---|---|
iconDiv |
The div that holds the icon. Value may be null. |
- Inherited from
- Blockly.ToolboxCategory#openIcon_
parseContents_
parseContents_(categoryDef)
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.
Parameter |
|
---|---|
categoryDef |
The information needed to create a category. Value must not be null. |
- Inherited from
- Blockly.CollapsibleToolboxCategory#parseContents_
refreshTheme
refreshTheme()
Updates the colour for this category.
- Inherited from
- Blockly.ToolboxCategory#refreshTheme
setDisabled
setDisabled(isDisabled)
Sets whether the category is disabled.
Parameter |
|
---|---|
isDisabled |
True to disable the category, false otherwise. |
- Inherited from
- Blockly.ToolboxCategory#setDisabled
setExpanded
setExpanded(isExpanded)
Opens or closes the current category.
Parameter |
|
---|---|
isExpanded |
boolean True to expand the category, false to close. |
setSelected
setSelected(isSelected)
Sets the current category as selected.
Parameter |
|
---|---|
isSelected |
True if this category is selected, false otherwise. |
- Inherited from
- Blockly.ToolboxCategory#setSelected
- Implements
- Blockly.ISelectableToolboxItem#setSelected
- Blockly.ICollapsibleToolboxItem#setSelected
setVisible_
setVisible_(isVisible)
Sets whether the category is visible or not. For a category to be visible its parent category must also be expanded.
Parameter |
|
---|---|
isVisible |
True if category should be visible. |
- Inherited from
- Blockly.CollapsibleToolboxCategory#setVisible_
show
show()
Show the category. Category will only appear if its parent category is also expanded.
- Inherited from
- Blockly.ToolboxCategory#show
toggleExpanded
toggleExpanded()
Toggles whether or not the category is expanded.
updateFlyoutContents
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.
Parameter |
|
---|---|
contents |
The contents to be displayed in the flyout. A string can be supplied to create a dynamic category. |
- Inherited from
- Blockly.ToolboxCategory#updateFlyoutContents
Abstract type
CssConfig
{container: nullable string, row: nullable string, rowcontentcontainer: nullable string, icon: nullable string, label: nullable string, selected: nullable string, openicon: nullable string, closedicon: nullable string, contents: nullable string}
All the css class names that are used to create a collapsible category. This is all the properties from the regular category plus contents.