addMenu Method

Description

Adds a menu to the editor's toolbar, if a toolbar exists.

Syntax

.addMenu(/* Object */ menuDefinition)

Parameters

menuDefinition: Object

A hash of values that define the new menu. The valid values are:

label — The text label of the menu.

showLabel — When false, the menu label will not be displayed. Instead, it will be used as a tooltip. The default value is true.

iconClass — An optional CSS class that defines the menu's icon. Note that when showLabel is false, an icon class must be specified for the menu.

menuItems — An array of menu item definitions. These are the selections that will shown when the menu is invoked. Each menu item definition is a hash containing:

label — The text label of the menu item.
iconClass — An optional CSS class that defines the menu item's icon.
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 ESDWeb(null, 'editorNode');

/* set editor properties here */

editor.startup();

In code that runs after the editor is started:

editor.addMenu({
	label: 'Custom Menu',
	showLabel: false,
	iconClass: 'customMenuIconClass',
	menuItems: [
		{
			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
		}
	]
});