From dca50fcec3f0ebbc8979b19cc8c18eca1724817a Mon Sep 17 00:00:00 2001 From: FWeinb Date: Tue, 17 Jun 2014 18:06:15 +0200 Subject: [PATCH] Update example to wait for app.on('ready') Related to Issue #383 --- docs/api/tray.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/api/tray.md b/docs/api/tray.md index f35fc4bdcf66..01aca310522c 100644 --- a/docs/api/tray.md +++ b/docs/api/tray.md @@ -4,18 +4,23 @@ A `Tray` represents an icon in operating system's notification area, it is usually attached with a context menu. ```javascript +var app = require('app'); var Menu = require('menu'); var Tray = require('tray'); -var appIcon = new Tray('/path/to/my/icon'); -var contextMenu = Menu.buildFromTemplate([ - { label: 'Item1', type: 'radio' }, - { label: 'Item2', type: 'radio' }, - { label: 'Item3', type: 'radio', clicked: true }, - { label: 'Item4', type: 'radio' }, -]); -appIcon.setToolTip('This is my application.'); -appIcon.setContextMenu(contextMenu); +var appIcon = null; +app.on('ready', function(){ + appIcon = new Tray('/path/to/my/icon'); + var contextMenu = Menu.buildFromTemplate([ + { label: 'Item1', type: 'radio' }, + { label: 'Item2', type: 'radio' }, + { label: 'Item3', type: 'radio', clicked: true }, + { label: 'Item4', type: 'radio' }, + ]); + appIcon.setToolTip('This is my application.'); + appIcon.setContextMenu(contextMenu); +}); + ``` __Platform limitations:__