Open
Description
index.html
<script>
const win = nw.Window.get();
let close = false;
win.on("close", () => {
alert(close);
if (close) win.close(true);
else close = true;
});
</script>
main.js
// When there is only one window, it works fine:
// first time: alert `false`
// second time: alert `true` -> close the window
nw.Window.open("index.html");
// When there are multiple windows, closing any window will trigger the "close" event twice, and then automatically close the window:
// first time: alert `false` -> alert `true` -> close the window
nw.Window.open("index.html");
nw.Window.open("index.html");