Modal dialog and the close button
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