Re: Newbie: Prompt Before Quitting
Re: Newbie: Prompt Before Quitting
- Subject: Re: Newbie: Prompt Before Quitting
- From: j o a r <email@hidden>
- Date: Wed, 9 Apr 2003 21:14:17 +0200
On Wednesday, Apr 9, 2003, at 20:39 Europe/Stockholm, Chad Eckles wrote:
Hello All Can someone show me how to Prompt the User if he Wants to
Quite or
not when he Closes the Window?
Make sure that your window controller / application controller is the
delegate of the window in question, and then implement this window
delegate method:
- (BOOL) windowShouldClose:(id) sender
{
return (NSRunAlertPanel(nil, @"Really Quit?", @"OK", @"Cancel", nil)
== NSAlertDefaultReturn);
}
...and then implement this method in your application delegate.
- (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication
*) theApplication
{
return YES;
}
This works if you have a single-window application. If not, you need to
call [NSApp terminate: nil] from the "windowShouldClose:" method.
j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.