On Aug 14, 2013, at 10:52:55, Graham Cox <graham....@bigpond.com> wrote:
> 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); > } I was trying something similar, but instead was using [NSApp [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:NO]; Which didn't work alone, so I added a 2nd: [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0.3] inMode:NSDefaultRunLoopMode dequeue:NO] Which worked about half the time. I just tried your method of runUntilDate with a time of 0.1 in the future and so far it's working every time. Thanks for that - I wasn't aware of this method. We'll give it a thorough testing. -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com