template
array|object - Menu template for initialize. The template take the options of Electron's Menu Itempath
string - add a menu item by path.message
string - Ipc message name.command
string - A global function in main process (e.g. Editor.log).params
array - The parameters passed through ipc.panel
string - The panelID, if specified, the message will send to panel.dev
string - Only show when Menu.showDev is true.
webContents
object - A WebContents object.
path
string - The menu pathtemplate
array|object
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.
path
string - The menu pathpos
numbertemplate
array|object
Build a template into menu item and insert it to path at specific position
Remove menu item at path.
template
array|object
Reset the menu from the template.
path
- The menu pathoptions
icon
NativeImage - A NativeImageenabled
booleanvisible
booleanchecked
boolean - NOTE: You must set your menu-item type to 'checkbox' to make it work
path
string - The menu pathtemplate
array|object
Update menu item at path.
Indicate if show dev menu
template
array|object - Menu template for initialize. The template take the options of Electron's Menu ItemwebContents
object - A WebContents object.
Convert the menu template to process additional keyword we added for Electron.
If webContents provided, the template.message
will send to the target webContents.
name
string - Name of the register menu
name
string - Name of the register menufn
function - A function returns the menu templateforce
boolean - Force to register a menu even it was registered before
name
string - Name of the register menu
template
array|object - Menu template for initialize. The template take the options of Electron's Menu Itemfn
function - Function applied to each menu item
Example:
Editor.Menu.walk(menuTmpl, item => {
if ( item.params ) {
item.params.unshift('Hello');
}
if (item.message === 'foobar:say-hello') {
item.enabled = false;
}
});