From 4556433f3b42d478432f991ab2a2a90dad15bdb3 Mon Sep 17 00:00:00 2001 From: nixxquality Date: Wed, 24 Apr 2019 18:53:15 +0200 Subject: [PATCH] docs: fully document MenuItem instance properties (#17479) * document menuItem instance properties * correct some types * add correct click documentation --- docs/api/menu-item.md | 57 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/docs/api/menu-item.md b/docs/api/menu-item.md index 45ab83d7d5c..9e274eb8ce4 100644 --- a/docs/api/menu-item.md +++ b/docs/api/menu-item.md @@ -122,6 +122,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 @@ -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. -#### `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.