Quit an application with sheet windows open

Sheet windows prevent the user from quitting the application while they’re open, even when displayed using.

sheetWindow.showWithin( window )

I’ve also set [NSWindow preventsApplicationTerminationWhenModal:No] and confirmed that this property is set to No/False.

The CancelClose event doesn’t fire in the sheet, nor does it fire in the application, so I am not able to manually close the sheet window.

Any other ideas?

@Greg_O_Lone is it possible that the Xojo Framework is preventing termination because it sees a sheet window is open?

Edit: I just tried to capture the AppleEvent, but that only is only capturable when sent from other apps. So I might have to capture the quit menu item, and the apple event, but will miss any other places in my app where app.quit might get called.

Edit 2: Overriding the FileQuit menuitem and capturing the “quit” AppleEvent is the best I can do right now, without replacing the application delegate.

1 Like

I am quitting apps with a frontmost sheet window by first closing the sheet window and then the app.

My “FileQuit” menuitem looks like:

Var w As Window = App.Window(0)
If (w <> Nil) And w.Visible Then
End If

Why would you want to? That is a recipe for data loss as sheet windows are mostly used for save dialogs …

I guess you could work around it with a global flag CloseWithoutSaving and a corresponding menu item …

For my situation, I have an information sheet that can appear on request. The contents of this sheet are not important and do not need to be saved.

For the “Do you want to save” dialogs in my application, they’re displayed as a sheet, but they’re MessageDialogs and I am not looking to auto-close them, just any instances of the “Info” sheet.

The problem is that cancelClose will not fire when a sheet is open. I think that this is a Xojo thing, but have not put in enough effort to confirm.

I have captured the FileQuit menuitem and the AppleEvent “Quit”, but if I call quit anywhere in my code, it silently fails, so I have had to update that also.


I did a little digging on this earlier this week and I did not find anything in our code that jumped out at me.

Thanks for looking.