Re: Modal dialog and the close button
Re: Modal dialog and the close button
- Subject: Re: Modal dialog and the close button
- From: Scott Andrew <email@hidden>
- Date: Wed, 22 Nov 2006 11:22:30 -0800
I should also state that this is main window for Photoshop plugin
that is ran modally. ;-) So it has a close button.
On Nov 22, 2006, at 10:51 AM, Stephane wrote:
On Nov 22, 2006, at 7:26 PM, Scott Andrew wrote:
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];
}
* I don't think the HIG (or what's left of it) recommends having a
close button in the title bar of a modal dialog.
* This solutions has been working fine till now for me:
-(IBAction)onChoice2:(id)sender
{
[NSApp stopModal]; // or [NSApp stopModalWithCode:mStatus];
[IBwindow_ orderOut:self];
}
For my part, I just use one method for all buttons (cancel, ok,
etc...) that will stop the dialog. Their tags help me know which
one was pressed.
_______________________________________________
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