Reputation: 2225
Is there a way to check if a tray icon already exists for given app in Node Webkit (on OSX)?
My problem looks like this:
Code used to create tray icon:
// Create a tray icon
if (os_platform === 'darwin'){ //better icon for windows, correct size for mac
var tray = new gui.Tray({ title: '', icon: 'icon-mac.png', tooltip: 'R' });
}
else {
var tray = new gui.Tray({ title: '', icon: 'icon-win.png', tooltip: 'R' });
}
Upvotes: 0
Views: 437
Reputation: 9401
I have just fixed this by using this:
win.on('restore', function() {
console.log('removing tray.');
tray.remove();
});
After analyzing the behavior I noticed that you can unminimize the app by clicking it on the taskbar. This listens for that as well.
Upvotes: 0
Reputation: 2225
This does the trick.
window.onbeforeunload = function(){
tray.remove();
};
Upvotes: 2