Re: Odd sheet behavior
Re: Odd sheet behavior
- Subject: Re: Odd sheet behavior
- From: Ryan Stevens <email@hidden>
- Date: Sun, 25 Aug 2002 23:28:33 -0700
Why not give the cancel and ok buttons tags and use one action for the
both of them that looks like...
- (void)closeTheDarnSheet:(id)sender
{
[NSApp stopModal]; // Needs done either way
if ([sender tag] == OK_BUTTON) {
[self doWhatever];
return;
}
if ([sender tag] == CANCEL_BUTTON) return; /* [self doSomethingElse]; */
// Somehow the tags aren't what we expect...
NSLog(@"Improper button tag, expecting: Cancel button == 0, OK Button ==
1");
}
Oh, yes, I almost missed the obvious too...
the first (correct) order was;
endSheet
orderOut
stopModal
then you changed it to;
stopModal *this should be last*
endSheet
orderOut
Not a big deal, I'm pretty sure I've done the exact same thing.
On Sunday, August 25, 2002, at 07:21 PM, David Newberry wrote:
Hello all,
I'm working on putting up a custom sheet. This is the code they offer
in the docs (modified for my app):
[NSApp beginSheet:Panel
modalForWindow:Window2
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
[NSApp runModalForWindow: Panel];
// Sheet is up here.
[NSApp endSheet:Panel];
[Panel orderOut:self];
They also note that this code needs to be put in the action for the
sheet'
s close button:
[NSApp stopModal];
All this works well, but my sheet has two buttons (OK and Cancel). I
could set a global var, but yuck! If I put up a new window in the OK
button's action, it gets shown before the sheet is hidden. Instead, I
thought I'd take this approach: I'd remove the two lines that get
called after stopModal is called and put them in my button actions. So
now I have this:
[NSApp beginSheet:Panel
modalForWindow:Window2
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
[NSApp runModalForWindow: Panel];
And in my Cancel action:
[NSApp stopModal];
[NSApp endSheet:Panel];
[Panel orderOut:self];
And in my OK action:
[NSApp stopModal];
[NSApp endSheet:Panel];
[Panel orderOut:self];
[self actionThatPutsUpANewWindow];
This appears to function properly the first time, but... doesn't. I
can't really describe the behavior that I get but it is most certainly
not right.
So it seems that for some reason endSheet: (and possibly also oderOut:)
have to be called from the method that puts up the sheet. That seems
pretty improbable... am I missing something obvious?
Thanks,
-David Newberry
_______________________________________________
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.
_______________________________________________
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.