Re: Series of sheets
Re: Series of sheets
- Subject: Re: Series of sheets
- From: Matt Neuburg <email@hidden>
- Date: Thu, 23 Aug 2007 14:20:33 -0700
- Thread-topic: Series of sheets
On Thu, 23 Aug 2007 10:36:26 -0700, John Stiles <email@hidden> said:
>I am wondering if Matt's code works anomalously because he never runs
>the event loop between showing the sheet and hiding it.
Then why not stop wondering, and try it? This works fine too:
- (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:self
didEndSelector:@selector(didEnd2:ret:ci:)
contextInfo:nil];
}
- (IBAction)closeThePanel:(id)sender {
[NSApp endSheet:[sender window]];
}
- (void) didEnd2:(NSWindow*)w ret:(int)ret ci:(void*)ci {
[w close];
}
In that code, myAction is the action of the button in the main window, and
closeThePanel is the action of the button in the sheet. You can't object
that the event loop never ran, or whatever the theory is supposed to be
here, because didEnd2 is clearly called.
I can do it all day: press the button in the window, dismiss the Open panel,
dismiss the panel sheet, rinse lather repeat. So, as I say, something is
going on in Randall's code that he hasn't deigned to share with us. I'd be
curious to know what it is. I suspect, as I said before, that it has to do
with the notion of "the same NSOpenPanel".
>Like Pierre says, I am pretty sure that normally code like this will
>not function but just beep.
Why would it beep? It sounds to me like there may be a problem with the way
*you* summon or dismiss a sheet. Maybe we should be talking about *that*?
>Matt's code isn't really representative
>of the issue because, by not running the event loop, I am pretty sure
>the app state changes significantly.
Whatever. I think I just disproved that.
>On Aug 23, 2007, at 10:28 AM, Pierre Bernard wrote:
>
>> Funny, I can't either drop a new sheet from the didEndSelector of
>> another one.
>>
>> What I have been doing is to performAfterDelay:0 for opening the
>> next sheet.
You will never see me minimize the value of delayed performance; I use it,
and advise it, a great deal. But this is not a case where it is needed. As
long as you call orderOut first thing in your didEndSelector, delayed
performance is not necessary in order to implement successive sheets; you
can go right on and summon the next sheet there and then. Let me know if I
need to modify my example *again* to prove *that*! :) m.
>>> On Tue, 21 Aug 2007 19:41:39 -0600, Randall Meadows <cocoa-dev@not-
>>> pc.com>
>>> 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.
--
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