Editor.Menu

Class: Editor.Menu

new Editor.Menu (template[, webContents])

Instance Methods

Build a template into menu item and add it to path

Example:

let editorMenu = new Editor.Menu();
editorMenu.add( 'foo/bar', {
  label: foobar,
  message: 'foobar:say',
  params: ['foobar: hello!']
});

// you can also create menu without label
// it will add menu to foo/bar where bar is the menu-item
let editorMenu = new Editor.Menu();
editorMenu.add( 'foo/bar/foobar', {
  message: 'foobar:say',
  params: ['foobar: hello!']
});

Clear all menu item in it.

De-reference the native menu.

Build a template into menu item and insert it to path at specific position

Remove menu item at path.

Reset the menu from the template.

Update menu item at path.

Static Properties

Editor.Menu.showDev

Indicate if show dev menu

Static Methods

Editor.Menu.convert (template[, webContents])

Convert the menu template to process additional keyword we added for Electron. If webContents provided, the template.message will send to the target webContents.

Editor.Menu.getMenu (name)

Editor.Menu.register (name, fn[, force])

Editor.Menu.unregister (name)

Editor.Menu.walk (template, fn)

Example:

Editor.Menu.walk(menuTmpl, item => {
  if ( item.params ) {
    item.params.unshift('Hello');
  }

  if (item.message === 'foobar:say-hello') {
    item.enabled = false;
  }
});

IPC Messages

Message: 'menu:popup'

Message: 'menu:register'