docs: menu must be added on whenReady (#28958)
This commit is contained in:
parent
2c65060ec8
commit
28143774c1
1 changed files with 16 additions and 0 deletions
|
@ -83,6 +83,22 @@ following code snippet to your menu template:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Make sure the application menu is added after the [`'ready'`](../api/app.md#event-ready)
|
||||||
|
event and not before, or the menu item will be disabled:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const { app, Menu } = require('electron')
|
||||||
|
|
||||||
|
const template = [
|
||||||
|
// Menu template here
|
||||||
|
]
|
||||||
|
const menu = Menu.buildFromTemplate(template)
|
||||||
|
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
Menu.setApplicationMenu(menu)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
![macOS Recent Documents menu item][menu-item-image]
|
![macOS Recent Documents menu item][menu-item-image]
|
||||||
|
|
||||||
When a file is requested from the recent documents menu, the `open-file` event
|
When a file is requested from the recent documents menu, the `open-file` event
|
||||||
|
|
Loading…
Reference in a new issue