Re: Series of sheets
Re: Series of sheets
- Subject: Re: Series of sheets
- From: Matt Neuburg <email@hidden>
- Date: Thu, 23 Aug 2007 10:22:13 -0700
- Thread-topic: Series of sheets
On Tue, 21 Aug 2007 19:41:39 -0600, Randall Meadows <email@hidden>
said:
>I know it can be done, but I can't figure out why, when I follow the
>sample code, it doesn't work for me.
>
>I display an NSOpenPanel using beginSheetForDirectory. I set the
>didEndSelector to one of my methods, and it's called appropriately.
>In that method, I call [panel close], then open my own sheet using
>[NSApp beginSheet...] just as is shown in the sample code at
><http://developer.apple.com/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingCa
scadingSheets.html>.
>After my task is finished, I then end my sheet with [NSApp
>endSheet:mySheet]; [mySheet orderOut:self].
>
>The next time I try to open that same NSOpenPanel, all I get is a
>system beep when I try to execute the beginSheetForDirectory call.
>
>In trying to figure this out, I changed the NSOpenPanel to be
>modeless (using [openPanel beginForDirectory...]), and then I ended
>up with the system beep when I tried to run my custom sheet again
>(got the beep when trying to execute [NSApp beginSheet...].
>
>I would appreciate any pointers to what I seem to be missing.
Since you don't post any of your code, it's hard to provide pointers. I
certainly can't reproduce your problem. My code looks like this:
- (IBAction)myAction:(id)sender
{
NSOpenPanel* op = [NSOpenPanel openPanel];
[op beginSheetForDirectory:nil file:nil types:nil
modalForWindow:[sender window]
modalDelegate:self
didEndSelector:@selector(didEnd:ret:ci:) contextInfo:sender];
}
- (void) didEnd:(NSOpenPanel*)op ret:(int)ret ci:(void*)ci {
[op close];
[NSApp beginSheet:thePanel modalForWindow:[(id)ci window]
modalDelegate:nil didEndSelector:nil contextInfo:nil];
sleep(3);
[NSApp endSheet:thePanel];
[thePanel orderOut:self];
}
That seems like the minimum required to reproduce the phenomenon you're
describing. I press the button (whose action is "myAction") and the Open
panel appears. I close it, and the sheet appears for three seconds and
vanishes. Repeat ad nauseam. Nothing bad happens.
Perhaps the problem lies in your use of the words "open that same
NSOpenPanel". I'm not quite sure what you mean by that, but it sounds like
you might be doing something you're not supposed to do.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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