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:

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
        }
    ]
);