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

macOS: Quit from the app switcher, missing "quit" string at event callback.

Open zdol opened this issue 10 years ago • 4 comments

On a Mac running mac OS 10.12, with nwjs (0.18.1) quitting the app from the app switcher (cmd+tab, keep the cmd pressed, highlight the app icon by pressing tab as many times it is needed and quit by pressing q, while still keeping cmd pressed) does not pass the "quit" string on the close event callback.

Quit by just pressing cmd+q, or selecting Quit from the file menu, or right-click and quit from the dock, all work just fine. It should be fixed I think.

var win = nw.Window.get();
win.on('close', function(e) {
    if (e === 'quit') {
      // code here should work in all cases
    }
}

zdol avatar Oct 21 '16 17:10 zdol

After some more extensive testing, it turns out that the event callback does not pass the 'quit' string when the app is not in the foreground, aka window does not have focus. One should handle the focus state properly and then handle any quit operations.

zdol avatar Oct 25 '16 11:10 zdol

I cannot reproduce this issue with NW.js between 0.17.6 to 0.18.7 on macOS 10.11 and 10.12.

How could you confirm code in the if statement not working?

ghostoy avatar Nov 16 '16 06:11 ghostoy

Close it since not receiving feedback for 2 weeks. Please reopen it if you have any follow ups.

ghostoy avatar Nov 29 '16 05:11 ghostoy

Seems to work as intended on 0.18.8, thanks.

zdol avatar Nov 29 '16 16:11 zdol