Loading document parsing libraries...
# Toolbar
Class
## About
`Toolbar` is the editor-owned ordered collection of `ToolbarSection` objects. The editor creates it automatically and exposes it through the read-only `Editor.Toolbar` property.
Modify the existing object rather than constructing or assigning a replacement. Sections form wrapping boundaries: when the editor is too narrow, wrapping occurs between sections instead of splitting a logical group arbitrarily.
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| Add | section As ToolbarSection | (None) | Adds the supplied section to the end of this toolbar. |
| AddAt | index As Integer <br> section As ToolbarSection | (None) | Inserts the supplied section at the specified zero-based index. |
| Destructor | (None) | (None) | Releases resources owned by this toolbar instance. |
| IndexOf | section As ToolbarSection | Integer | Returns the zero-based index of the supplied section, or -1 when absent. |
| Item | identifier As String | ToolbarItem | Returns the toolbar item with the supplied identifier, or Nil when absent. |
| LastIndex | (None) | Integer | Returns the last zero-based section index, or -1 when there are no sections. |
| Remove | section As ToolbarSection | (None) | Removes the matching section from this toolbar. |
| RemoveAll | (None) | (None) | Removes every section from this toolbar. |
| RemoveAt | index As Integer | (None) | Removes the section at the specified zero-based index. |
| Section | type As ToolbarSection.Types | ToolbarSection | Returns the first toolbar section of the specified type, or Nil when absent. |
| SectionAt | index As Integer | ToolbarSection | Returns the toolbar section at the specified zero-based index. |
| Sections | (None) | ToolbarSection | Returns a copy of the toolbar's sections. |
## Notes
Toolbar changes are instance-specific and can be made at runtime.
### Default Sections and Items
The editor builds four sections, in this order. Find one with `Section` and an item with `Toolbar.Item` or `ToolbarSection.Item` and its identifier.
- `Nodes`: one item for each registered node type, followed by `delete`, which deletes the selected nodes. A node type's item identifier is `node:` followed by its type, for example `node:text`, `node:heading`, `node:image`, `node:table`, `node:list`, `node:quote`, `node:alert`, `node:codeblock`, `node:rawcontent`, `node:columns`, `node:divider`, `node:pagebreak`, `node:audio`, `node:video`, and for forms `node:form`, `node:label`, `node:textfield`, `node:textarea`, `node:select`, `node:checkbox`, `node:radiogroup`, `node:button`, and `node:datalist`. `TextNode` and `HeadingNode` are registered by default; the others appear when registered.
- `Font`: `font`, `size`, `bold`, `italic`, `underline`, `strike`, `lineheight`, and `linespacing`.
- `Formatting`: `alignment`, `textcolor`, `background`, `link`, and `clearformatting`.
- `Output`: `print`.
The selected node's popover toolbar adds `move`, `duplicate`, and `delete`, plus `resizewidth` and `resizeheight` for resizable nodes, after the node's own items.
```xojo
'// Put application commands before Print, and move Delete to the end.
Var outputSection As GraffitiProEditor.ToolbarSection = Editor.Toolbar.Section(GraffitiProEditor.ToolbarSection.Types.Output)
outputSection.AddAt(outputSection.IndexOf(outputSection.Item("print")), previewItem)
Var nodesSection As GraffitiProEditor.ToolbarSection = Editor.Toolbar.Section(GraffitiProEditor.ToolbarSection.Types.Nodes)
nodesSection.Add(nodesSection.Item("delete"))
```
### Runtime Customization
Use `Section` to retrieve a default section, or use the indexed collection methods to replace the complete arrangement. Changes made directly to the toolbar, sections, or items refresh the owning editor.
Call `RemoveAll` when building a completely custom toolbar. Add custom sections in their intended display order and add the deletion item at the desired location rather than relying on numeric item-order properties.
## Examples
Build application-specific arrangements from sections and items.
### Adding a Custom Section
```xojo
Var section As New GraffitiProEditor.ToolbarSection(GraffitiProEditor.ToolbarSection.Types.Custom)
Var item As New GraffitiProEditor.ToolbarItem("preview", "Preview")
item.Tooltip = "Preview exported HTML"
section.Add(item)
Editor.Toolbar.Add(section)
```