addMenu
addMenu Method
Description
Adds a custom menu to the toolbar of the editor (if the toolbar is enabled).
.addMenu(/* Object[] */ menuItems)
Parameters
menuItems
Array
An array of menu item definitions. These are the selections that will be shown when the custom menu is opened. Each menu item definition is a hash containing:
-
label
StringThe text label of the menu item.
-
iconClass
StringAn optional CSS class that defines the icon of the menu item.
-
onClick
FunctionAn optional function that will be executed when the menu item is selected.
-
menuItems
ArrayAn optional array of sub-menu items to be associated with the menu item. These sub-menu items have the same form as top-level menu items. Note that onClick and menuItems are mutually exclusive.
Example
editor = new window.__editor(undefined, document.getElementById('editor-node'));
/* set editor properties here */
editor.startup();
In code that runs after the editor is started:
editor.addMenu([
{
label: 'Print',
showLabel: true,
onClick: printDiagram
},
{
label: 'Unit of Measurement',
showLabel: true,
menuItems: [
{
label: 'Meters',
showLabel: true,
onClick: function () {
editor.set('uom', 'meters');
}
},
{
label: 'Feet and Inches',
showLabel: true,
onClick: function () {
editor.set('uom', 'feetAndInches');
}
},
{
label: 'Feet and Tenths',
showLabel: true,
onClick: function () {
editor.set('uom', 'feetAndTenths');
}
}
]
},
{
label: 'Download Diagram File...',
showLabel: true,
onClick: downloadDiagramFile
}
]
);