From 6f8eb282b77b2a63a0257f97e14a8b0492051b9e Mon Sep 17 00:00:00 2001 From: Alexandre Date: Tue, 15 Nov 2016 21:53:54 +0100 Subject: [PATCH] [ci skip] Correct Linux limitation example --- docs/api/tray.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/api/tray.md b/docs/api/tray.md index 660d703c4abe..1e1d8524aaaa 100644 --- a/docs/api/tray.md +++ b/docs/api/tray.md @@ -33,18 +33,22 @@ __Platform limitations:__ you have to call `setContextMenu` again. For example: ```javascript -const {Menu, Tray} = require('electron') -const appIcon = new Tray('/path/to/my/icon') -const contextMenu = Menu.buildFromTemplate([ - {label: 'Item1', type: 'radio'}, - {label: 'Item2', type: 'radio'} -]) +const {app, Menu, Tray} = require('electron') -// Make a change to the context menu -contextMenu.items[2].checked = false +let appIcon = null +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 -appIcon.setContextMenu(contextMenu) + // Make a change to the context menu + 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.