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-
32x32.png" );
this.tray = new nw.Tray(...