Nw.js: NW.js icon on the taskbar when you open a tray menu

Created on 7 Nov 2018  路  9Comments  路  Source: nwjs/nw.js

NW.js Version: sdk-v0.34.1
Operating System: Windows 10 x64, Windows 7 x64

How to reproduce

You can use the code for create simple tray object and hide main window:

let menu = new nw.Menu();
let path = require("path");
// Test icon for tray object
let icon = path.resolve(path.dirname(process.execPath), "icon.png");
menu.append(new nw.MenuItem({ label: 'Item A' }));
menu.append(new nw.MenuItem({ label: 'Item B' }));
new nw.Tray({title: "Test title", icon, menu});
// Hide main window
nw.Window.get().hide();

After this, if you open tray context menu, nwjs icon show on thw windows taskbar:
https://youtu.be/8CHHSMFjsGk

bug platform-specific

Most helpful comment

Confirmed the issue and it is still happening in the latest version [nwjs-sdk-v0.39.0-win-x64].
As @TheJaredWilcurt said, in version 0.33.4 is okay!

All 9 comments

Confirmed that issue only occurs in 0.34.0-beta and above. Issue not present in 0.33.4 or below.

Reproduction package.nw folder attached:

Any update on this - it's much worse in Windows 7 as it shows not just the small ICON as it does in Windows 10.

Screen Shot 2019-03-30 at 2 10 21 am

Same issue at 0.37.3

I can reproduce this with v0.34 & later version.

Confirmed the issue and it is still happening in the latest version [nwjs-sdk-v0.39.0-win-x64].
As @TheJaredWilcurt said, in version 0.33.4 is okay!

One year has passed, v0.42.4 has been released, but the issue still not fix.

@rogerwang: Is there a way I can handle this in code? That is on right-click on tray icon I should be able to hide nwjs icon on the taskbar .

@anurag2911 the tray feature only supports a native menu on right-click (which causes this bug) and a click event on left-click.

tray.on('click', function (evt) {
  nw.Window.get().showDevTools();
  console.log(evt.x);
  console.log(evt.y);
});

Using the x,y coords, you could spawn a custom frameless window that simulates a menu at that location. Frameless windows with show_in_taskbar: false will not cause this issue. This is of course a hack, but would allow for much greater control over the rendering of the menu.

@rogerwang

The diff between the versions is pretty small, could you identify the cause?

tray bug gif

Was this page helpful?
0 / 5 - 0 ratings