Skip to content

Commit

Permalink
docs: fully document MenuItem instance properties (#18785)
Browse files Browse the repository at this point in the history
* document menuItem instance properties

* correct some types

* add correct click documentation
  • Loading branch information
trop[bot] authored and codebytere committed Jun 14, 2019
1 parent bf9b001 commit c0e688f
Showing 1 changed file with 53 additions and 4 deletions.
57 changes: 53 additions & 4 deletions docs/api/menu-item.md
Expand Up @@ -119,6 +119,50 @@ Lowercase `role`, e.g. `toggledevtools`, is still supported.

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`

A `Boolean` indicating whether the item is enabled, this property can be
Expand All @@ -142,10 +186,15 @@ will turn off that property for all adjacent items in the same menu.

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.

0 comments on commit c0e688f

Please sign in to comment.