nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

win.requestAttention() doesn't work in NW.js 0.50.x

Open AshleyScirra opened this issue 5 years ago • 6 comments

NWJS Version : reproduces in both 0.50.0 and 0.50.3 Operating System : Windows 10 64-bit

Expected behavior

The window 'requestAttention' method should work.

Actual behavior

It doesn't seem to work in 0.50.x. It logs a console error: Unchecked runtime.lastError: The context from which the function was called did not have an associated app window.

How to reproduce

Minimal repro: win-requestattention.zip

Click the button. It just runs: nw.Window.get().requestAttention(3);

AshleyScirra avatar Jan 19 '21 15:01 AshleyScirra

I am also seeing this behavior with NW.js 0.58.0. This fails in all of the following scenarios:

nw.Window.open('page.html', (newWindow) => {
  newWindow.requestAttention(true);
});
nw.Window.get().requestAttention(true);
nw.Window.get().requestAttention(false);
nw.Window.get().requestAttention(3);

These all fail with the same error @AshleyScirra mentioned:

Unchecked runtime.lastError: The context from which the function was called did not have an associated app window.

sysrage avatar Nov 16 '21 16:11 sysrage

@rogerwang I hate to ping you but this sure looks like it'd be an easy fix and has been open for almost a year. Any input?

sysrage avatar Nov 16 '21 16:11 sysrage

@rogerwang This is still broken with 0.62.0.

sysrage avatar Mar 10 '22 14:03 sysrage

seem i got the same error on 0.82.0 image

deltapath-eric avatar Nov 14 '23 06:11 deltapath-eric

The problem still exists in 0.85.0

ssnangua avatar Mar 18 '24 13:03 ssnangua

An alternative solution:

const win = nw.Window.get();
chrome.windows.update(win.cWindow.id, { drawAttention: true });

ssnangua avatar Jan 19 '25 13:01 ssnangua