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: Graham Cox <email@hidden>
- Date: Wed, 14 Aug 2013 17:52:55 +0200
On 14/08/2013, at 5:10 PM, Steve Mills <email@hidden> wrote:
> The header comment for runModal says "It returns only after the user has closed the panel." The key word here is "closed", which makes it seem like the window should indeed close, not be marked for closure at some later time.
Well, there's logically 'closed' and there's having the pixels on the screen removed or updated. The run loop has to run for that to happen in the normal course of things.
Design flaw or not (and it's arguable - the continued presence of the Open dialog until there is something new to show could be designed to give the user the feeling that 'something is happening') that's the way it is and like every other app it seems you're stuck with it. File a radar.
The only other thing you might try is running the run loop a few cycles in your completion handler so that the orderOut: is processed. It might have unexpected side-effects though, which might also reveal a very good reason why it's not done by default. For example, this works to close the panel immediately:
NSOpenPanel* p = [NSOpenPanel openPanel];
if([p runModal] == NSFileHandlingPanelOKButton)
{
[p orderOut:self];
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
// Simulate code that takes 5 seconds to open a document:
sleep(5);
}
>> You claim that opening the file on a thread doesn't help - I would expect it to since the main loop can run much sooner.
>
> I didn't claim it didn't help. I said it doesn't work in our case. Were we a simple Cocoa app without years of legacy and cross-platform code to contend with, then yeah, we could easily stick the file opening code in a background thread.
OK, that's understandable. But it also means you're stuck - you've tried what you can. File a radar, move on.
--Graham
_______________________________________________
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