Skip to content

Unable to set up a confirm before app close function. #8329

@Allasso

Description

@Allasso

(MacOS)

Using this:

win.on("close", () => {
  if (confirm("close window?")) {
    win.close(true);
  }
});

If I confirm close, app closes fine. If I don't confirm, I am no longer able to close the app, I need to force quit. I tried to re-attach the listener:

win.on("close", () => {
	handleWinClose();
});

function handleWinClose() {
  if (confirm("close window?")) {
		win.close(true);
  } else {
		win.on("close", () => {
			handleWinClose();
		});
  }
};

but it doesn't help. Apparently the "close" event is only fired once, ever. Any workaround for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions