May 25, 2021 Electron
The menu item module allows you to add options to an app or menu.
View the menu example.
Use the following
method to create a
MenuItem
options
Object
click
Function - When a menu
item is clicked,
click(menuItem,browserWindow)
role
String - Defines the
behavior of menu items and is
click
the click property is specified
type
String -
Take the value
normal
separator
checkbox
radio
label
String
sublabel
String
accelerator
Accelerator
icon
NativeImage
enabled
Boolean
visible
Boolean
checked
Boolean
submenu
Menu -
Should be a specific type of
submenu
menu item that can be ignored when it is a specific type of
type: 'submenu'
menu item.
If its
value is not
Menu
it will automatically change to
Menu.buildFromTemplate
id
String - flags the uniqueness of a menu.
If used by definition, it will be used as a reference location property for this menu item.
position
String - Defines the specific location information for a given menu.
When you create a menu item,
if there is a matching method, it is recommended
role
without human action on its behavior, so that menu usage can give the user the best experience.
role
property value can be:
undo
redo
cut
copy
paste
selectall
minimize
- Minimizes the current window
close
- Close the current window
On OS X, the
role
have the following values:
about
-
Matches
orderFrontStandardAboutPanel
behavior
hide
-
Matches the
hide
behavior
hideothers
-
Match
hideOtherApplications
behavior
unhide
-
Matches
unhideAllApplications
behavior
front
-
Matches
arrangeInFront
behavior
window
- "Window" menu item
help
- "Help" menu item
services
- "Services" menu item