Hello!
There's a post from 4 years ago (https://www.construct.net/en/forum/construct-2/how-do-i-18/window-close-113911) about being able to run an event before the NWjs window closes when pressing the X(close) button of the actual window. Rojohound gave an example of how this can be done at the bottom of the post, and I was hoping it would still work to this day, seeing as the NWjs documentation is still the same for the solution. However, it has proven futile for me.
I wanted to put up a confirmation window before the game closes when pressing the x button of the actual window. So I adapted the javascript code given in the post linked above to this:
"var win=nw.Window.get(); win.on('close', function() {c2_callFunction('nw.js close',[]);});"
As you can see, I omitted the win.close(true);
which is supposed to result in the window being prevented from closing (NWjs documentation example: https://docs.nwjs.io/en/latest/References/Window/#wincloseforce), but alas, doesn't work.
Maybe construct 2 is executing a window close event sometime later and thus overwriting the browser execute javascript event in the event sheet?
I've got the latest NWjs version (11th nov. 2020) for construct 2 and the latest version of construct 2 (279). Trying to run this on a Windows 8.1 pro computer.
Anyone who has any info on this? R0J0hound?