Re: Dismissing Open dlog before doc actually opens
Re: Dismissing Open dlog before doc actually opens
- Subject: Re: Dismissing Open dlog before doc actually opens
- From: Rainer Brockerhoff <email@hidden>
- Date: Wed, 14 Aug 2013 16:35:28 -0300
On 14/08/13 16:00 , email@hidden wrote:
Date: Wed, 14 Aug 2013 14:58:42 -0400
Message-ID: <email@hidden>
On Wed, 14 Aug 2013 09:03:59 -0500, Steve Mills said:
There most certainly is not a deeper issue with my code. Run this and
you'll see for yourself:
-(IBAction) openDocument:(id)sender
{
NSOpenPanel* p = [NSOpenPanel openPanel];
if([p runModal] == NSFileHandlingPanelOKButton) {
[p orderOut:self];
// Simulate code that takes 5 seconds to open a document:
sleep(5);
}
}
Apologies for being late to the thread.
I have a similar situation: the NSOpenPanel references a potentially
large document which may take nearly a minute to fully open. (I don't
use NSDocument, however.)
My solution was to pre-create an empty document window and attach the
NSOpenPanel to it as a modal sheet with a completion handler like this:
NSOpenPanel* panel = [NSOpenPanel openPanel];
[panel beginSheetModalForWindow:theWindow completionHandler:^(NSInteger
result) {
if (result==NSFileHandlingPanelOKButton) {
[self performSelectorOnMainThread:@selector(openTheseURLS:)
withObject:[panel URLs] waitUntilDone:NO];
}
}
I don't need to call orderOut: at all. The main runloop will close the
sheet and then process the selected URLs, updating the window as it does so.
Not sure how this would play out with NSDocument though... :-/
HTH,
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
http://brockerhoff.net/blog/
_______________________________________________
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