I like to send my app to a screen allowing data to be saved or cancelling exiting the app. This works fine except when you do a Command+Q or close from the application menu.
Searching so far hasn’t turned up a solution that works.
I just created a sample project (empty) with App CancelClosing and it breaks when using Command+Q
What did you try? Any sample code that you can share?
From the docs:
CancelClosing is called first. If, for any reason, you want to stop the termination process or interact with the user (use a modal window in such a case) to confirm, you should do it in this event. If you return True, the termination process will be stopped immediately.
That’s an idea. I just noticed that it’s not an issue in Windows. The first Alt-F4 goes to the window I want to allow data save or whatever. The second time Alt-F4 is pressed it exits which is fine for me. The issue appears tone dealing with it on the Mac.
Well it would do. I use app.CancelClosing to start some final actions, which include running a thread and setting a flag, app.quitting, to True (app.quitting is false normally). Then I Return True to cancel the quit and allow the final actions to complete.
When they are done, I have the thread make a UserInterfaceUpdate request, which simply calls Quit again. This time when my CancelClosing checks Quitting, it is True so it Returns False without doing anything else. App then quits as expected. Simples.