node.js - Context menu click/open event with Atom Shell/Electron? -


i'm trying capture click on tray icon click context menu on osx, according docs disabled in osx reason:

platform limitations:  on os x clicked event ignored if tray icon has context menu. 

i've wondering if there way know when tray icon context menu interacted with?

relavent code:

var app = require('app'); var path = require('path') var menu = require('menu'); var menuitem = require('menu-item'); var tray = require('tray');  var appicon = null; var menu = null; app.on('ready', function(){   appicon = new tray(path.join(__dirname, 'images/icon.png'));    appicon.on('clicked', function(event, bounds) {       console.log('clicked');   });    menu = new menu();    menu.append(new menuitem({ label: 'quit', id: 'quit', click: function() { app.quit(); } }));   appicon.setcontextmenu(menu);  }); 

now works on os x (10.11.4).

please check. main.js:

// load in dependencies var app = require('app'); var tray = require('tray');  // when electron has loaded app.on('ready', function onready () {   // log console verify logging works   console.log('hello world!');    // create tray   var tray = new tray(__dirname + '/icon.png');    // when tray icon clicked, log our console   tray.on('click', function handleclicked () {     console.log('tray clicked');   }); }); 

run:

electron main.js 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -