docs: fully document MenuItem instance properties (#17479)
* document menuItem instance properties * correct some types * add correct click documentation
This commit is contained in:
parent
253d049ac9
commit
4556433f3b
1 changed files with 53 additions and 4 deletions
|
@ -122,6 +122,50 @@ Lowercase `role`, e.g. `toggledevtools`, is still supported.
|
||||||
|
|
||||||
The following properties are available on instances of `MenuItem`:
|
The following properties are available on instances of `MenuItem`:
|
||||||
|
|
||||||
|
#### `menuItem.id`
|
||||||
|
|
||||||
|
A `String` indicating the item's unique id, this property can be
|
||||||
|
dynamically changed.
|
||||||
|
|
||||||
|
#### `menuItem.label`
|
||||||
|
|
||||||
|
A `String` indicating the item's visible label, this property can be
|
||||||
|
dynamically changed.
|
||||||
|
|
||||||
|
#### `menuItem.click`
|
||||||
|
|
||||||
|
A `Function` that is fired when the MenuItem receives a click event.
|
||||||
|
It can be called with `menuItem.click(event, focusedWindow, focusedWebContents)`.
|
||||||
|
* `event` [KeyboardEvent](structures/keyboard-event.md)
|
||||||
|
* `focusedWindow` [BrowserWindow](browser-window.md)
|
||||||
|
* `focusedWebContents` [WebContents](web-contents.md)
|
||||||
|
|
||||||
|
#### `menuItem.submenu`
|
||||||
|
|
||||||
|
A `Menu` (optional) containing the menu
|
||||||
|
item's submenu, if present.
|
||||||
|
|
||||||
|
#### `menuItem.type`
|
||||||
|
|
||||||
|
A `String` indicating the type of the item.
|
||||||
|
|
||||||
|
#### `menuItem.role`
|
||||||
|
|
||||||
|
A `String` (optional) indicating the item's role, if set.
|
||||||
|
|
||||||
|
#### `menuItem.accelerator`
|
||||||
|
|
||||||
|
A `String` (optional) indicating the item's accelerator, if set.
|
||||||
|
|
||||||
|
#### `menuItem.icon`
|
||||||
|
|
||||||
|
A `NativeImage | String` (optional) indicating the
|
||||||
|
item's icon, if set.
|
||||||
|
|
||||||
|
#### `menuItem.sublabel`
|
||||||
|
|
||||||
|
A `String` indicating the item's sublabel, this property can be dynamically changed.
|
||||||
|
|
||||||
#### `menuItem.enabled`
|
#### `menuItem.enabled`
|
||||||
|
|
||||||
A `Boolean` indicating whether the item is enabled, this property can be
|
A `Boolean` indicating whether the item is enabled, this property can be
|
||||||
|
@ -145,10 +189,15 @@ will turn off that property for all adjacent items in the same menu.
|
||||||
|
|
||||||
You can add a `click` function for additional behavior.
|
You can add a `click` function for additional behavior.
|
||||||
|
|
||||||
#### `menuItem.label`
|
#### `menuItem.registerAccelerator`
|
||||||
|
|
||||||
A `String` representing the menu items visible label.
|
A `Boolean` indicating if the accelerator should be registered with the
|
||||||
|
system or just displayed, this property can be dynamically changed.
|
||||||
|
|
||||||
#### `menuItem.click`
|
#### `menuItem.commandId`
|
||||||
|
|
||||||
A `Function` that is fired when the MenuItem receives a click event.
|
A `Number` indicating an item's sequential unique id.
|
||||||
|
|
||||||
|
#### `menuItem.menu`
|
||||||
|
|
||||||
|
A `Menu` that the item is a part of.
|
||||||
|
|
Loading…
Reference in a new issue