• 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
Modal dialog and the close button
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Modal dialog and the close button


  • Subject: Modal dialog and the close button
  • From: Scott Andrew <email@hidden>
  • Date: Wed, 22 Nov 2006 10:26:08 -0800

So i have a question. I am a bit confused about modal dialogs and the close button in the title bar.

What i do now is for each of my buttons i call [[self window]close], i also set a return code before hand. Then i add a windowWillClose handler and call stopModalWithCode returning the status. This so that the close button will also force a stopModal and return the default value for the status.

is there a better way to do this, or is this the best way? The code looks like so:

-(IBAction)onChoice1:(id)sender
{
	mStatus = choice1;
	[[self window] close];
}

-(IBAction)onChoice2:(id)sender
{
	mStatus = choice2;
	[[self window] close];
}

// put stop modal here so we can handle the close button in the title bar.
-(void)windowWillClose:(NSNotification *)aNotification
{
[NSApp stopModalWithCode:mStatus];
}
_______________________________________________


Cocoa-dev mailing list      (email@hidden)

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


  • Follow-Ups:
    • Re: Modal dialog and the close button
      • From: Stephane <email@hidden>
  • Prev by Date: Replacing Info.plist programmatically
  • Next by Date: Re: Replacing Info.plist programmatically
  • Previous by thread: Re: Replacing Info.plist programmatically
  • Next by thread: Re: Modal dialog and the close button
  • Index(es):
    • Date
    • Thread