Terminate App While NSSheet Is Visible?
Terminate App While NSSheet Is Visible?
- Subject: Terminate App While NSSheet Is Visible?
- From: "Chunk 1978" <email@hidden>
- Date: Sun, 3 Aug 2008 17:55:26 -0400
hi there. i've noticed on some applications that it's possible to quit an
app while an NSSheet is present, but i can't seem to correctly add this
functionality into my own app. an example: open Safari > View > Customize
Toolbar > Quit Safari. you'll notice that the sheet ends and then safari
terminates. the best i can come up with is the following, but while trying
to quit while the sheet is visible, the program returns NSBeep() instead.
any help would be appreciated:
#import "AppController.h"
@implementation AppController
- (IBAction)beginSheet:(id)sender
{
[NSApp beginSheet:theSheet modalForWindow:theWindow modalDelegate:nil
didEndSelector:NULL contextInfo:NULL];
}
- (IBAction)endSheet:(id)sender
{
[NSApp endSheet:theSheet];
[theSheet orderOut:nil];
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
{
if ([theSheet isKeyWindow])
{
NSLog (@"App Quit With Active Sheet");
[self endSheetThenQuit];
return NO;
}
else
{
NSLog (@"App Quit");
return YES;
}
}
- (void)endSheetThenQuit
{
[NSApp endSheet:theSheet];
[theSheet orderOut:nil];
[NSApp terminate];
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden