• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie: Prompt Before Quitting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Newbie: Prompt Before Quitting (From: Chad Eckles <email@hidden>)

  • Prev by Date: NSButton>Square Button>No Border Mouse Click Help
  • Next by Date: iTunes like display
  • Previous by thread: Newbie: Prompt Before Quitting
  • Next by thread: Re: Newbie: Prompt Before Quitting
  • Index(es):
    • Date
    • Thread