Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to prompt to save / quit before closing window due to defect of appWindow.close #5

Open
taodongl opened this issue May 1, 2023 · 1 comment

Comments

@taodongl
Copy link

taodongl commented May 1, 2023

"onCloseRequested" can be caught if clicking "Close window" in taskbar, but it is bypassed if clicking customized "close" button in right-top of window

const unlisten = await appWindow.onCloseRequested(async (event) => {
    const confirmed = await confirm('Are you sure?');
    if (!confirmed) {
      event.preventDefault();
    } else {
      unlisten();
    }
  });

It is limitation of Tauri, Could you replace appWindow.close with other function? (I try to replace it with process.exit(), but it also cannot trigger 'tauri://close-requested' event :()

Refer to: tauri-apps/tauri#5288 (comment)
Refer another: tauri-apps/plugins-workspace#254

@elibroftw
Copy link
Owner

Modify titlebar.jsx to call your function manually before closing the window. At least until v2 is released. V2 should also add the tu title() function that is erroring at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants