Allow application to close while sheet is displayed.

I have a sheet that attaches to my main window. This is an entry sheet that should not allow you to interact with the application until it is completed (modal default value). HOWEVER, I would like the user to be able to shut down the application. IE, they understand that they need a login, give up and want to close the application. The default behavior is to play NSBeep and continue to work. How can I override this?

+3
source share
3 answers

If you call endSheet:immediately after the sheet is shown, this will give the behavior I'm looking for.

[NSApp beginSheet:self._loginController.window
   modalForWindow:self.window
    modalDelegate:nil
   didEndSelector:nil
      contextInfo:NULL];
[NSApp endSheet:self._loginController.window];

This does not cancel the sheet, and when you are done, you can hide the sheet with [window orderOut:nil];.

0

10.6 , . :

[myModalSheet setPreventsApplicationTerminationWhenModal:NO];
+5

, , , . (/ ) .

, . , -, , , , .

+1

All Articles