O'Reilly logo

Cross-platform Desktop Application Development: Electron, Node, NW.js, and React by Dmitry Sheiko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Taking advantage of the system tray

In Chapter 2, Creating a File Explorer with NW.js – Enhancement and Delivery , we already examined adding and managing the application menu in the system tray. Briefly, we created menu items with nw.MenuItem, added them to the nw.Menu instance, and attached the menu to nw.Tray. So, the boilerplate for the tray menu may look as follows:

./js/Service/Tray.js

const appWindow = nw.Window.get();   export default class Tray {     tray = null;     constructor( ) {     this.title = nw.App.manifest.description;     this.removeOnExit();   }     getItems = () => {     return [ /* */ ];   }     render(){     if ( this.tray ) {       this.tray.remove();     }       const icon = "./assets/" +  ( process.platform === "linux" ? "icon-48x48.png" : "icon- ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required