custom-menu-click events fire on all three platforms. See Platform differences for details.
Setting a global menu
Callapp.setMenu(options) before or after creating windows. The menu applies to all windows that do not have a per-window override.
Handling menu clicks
Listen forcustom-menu-click on the Application instance. The event payload contains a customMenuEvent object with the id you assigned to the menu item and the windowId of the window that was frontmost when the item was activated.
id property emit this event. Role-based items such as copy and paste are handled natively by the OS and do not emit custom-menu-click.
Updating menus at runtime
Replace the entire menu tree at any time by callingapp.setMenu() again with a new item list. Pass null to remove the menu bar entirely.
Per-window menus
Callwin.setMenu() to assign a menu that applies only to a specific window. This overrides the global menu for that window. Clicks still emit custom-menu-click on the application.
Keyboard accelerators
Specify accelerators with theaccelerator property on any custom menu item. Use the following cross-platform modifier tokens:
Predefined roles
Userole instead of id + label to get OS-native behavior without writing click handlers. Role items are rendered and wired by the platform.
Nested submenus
Nest asubmenu inside any top-level or secondary menu item to create hierarchical menus.
Platform differences
On Linux, WebviewJS uses Muda’s GTK integration to attach a per-window menu
bar. Both
app.setMenu() and win.setMenu() work, and custom-menu-click
events fire as expected. The visual appearance is determined by the GTK theme
of the desktop environment.Related pages
- Multiple Windows — per-window menus and window lifecycle
- Application API reference —
setMenu,on('custom-menu-click'), and application events