addMenu Method

Description

Adds a custom menu to the toolbar of the editor (if the toolbar is enabled).

Syntax

.addMenu(/* Object[] */ menuItems)

Parameters

menuItems — 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 — The text label of the menu item.
iconClass — An optional CSS class that defines the icon of the menu item.
onClick — An optional function that will be executed when the menu item is selected.
menuItems — An 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
	}
]
);