[ci skip] Correct Linux limitation example
This commit is contained in:
parent
301b8ec39a
commit
6f8eb282b7
1 changed files with 14 additions and 10 deletions
|
@ -33,18 +33,22 @@ __Platform limitations:__
|
||||||
you have to call `setContextMenu` again. For example:
|
you have to call `setContextMenu` again. For example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {Menu, Tray} = require('electron')
|
const {app, Menu, Tray} = require('electron')
|
||||||
const appIcon = new Tray('/path/to/my/icon')
|
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
|
||||||
{label: 'Item1', type: 'radio'},
|
|
||||||
{label: 'Item2', type: 'radio'}
|
|
||||||
])
|
|
||||||
|
|
||||||
// Make a change to the context menu
|
let appIcon = null
|
||||||
contextMenu.items[2].checked = false
|
app.on('ready', () => {
|
||||||
|
appIcon = new Tray('/path/to/my/icon')
|
||||||
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
|
{label: 'Item1', type: 'radio'},
|
||||||
|
{label: 'Item2', type: 'radio'}
|
||||||
|
])
|
||||||
|
|
||||||
// Call this again for Linux because we modified the context menu
|
// Make a change to the context menu
|
||||||
appIcon.setContextMenu(contextMenu)
|
contextMenu.items[1].checked = false
|
||||||
|
|
||||||
|
// Call this again for Linux because we modified the context menu
|
||||||
|
appIcon.setContextMenu(contextMenu)
|
||||||
|
})
|
||||||
```
|
```
|
||||||
* On Windows it is recommended to use `ICO` icons to get best visual effects.
|
* On Windows it is recommended to use `ICO` icons to get best visual effects.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue