Re: Faking out modality with validateMenuItem:
Re: Faking out modality with validateMenuItem:
- Subject: Re: Faking out modality with validateMenuItem:
- From: Jeffrey Johnson <email@hidden>
- Date: Tue, 5 Dec 2006 13:43:21 -0500
On 12/5/06 at 9:36 AM, email@hidden (glenn andreas) wrote:
>
>On Dec 5, 2006, at 9:24 AM, Jeffrey Johnson wrote:
>
>> Alas, NSURLConnection is broken for modality- you (or your WebView)
>> can make outbound NSURLConnections while modal, but as long as
>> modality is "on", your connection:didRecieveXXX callbacks will
>> never be called, even if the delegate to handle those requests is
>> the modal window- apparently the modal filter discards the incoming
>> results. This has been known about for at least three years, by
>> searching the list archives.
>
>I believe the problem is NSURLConnection runs its receiving in run
>loop modes that don't include the modal one. I've used WebViews in
>modal dialogs by writing a custom modal session - so instead of doing
>runModalForWindow, use beginModalSessionForWindow: and inside that
>loop add:
>
> [[NSRunLoop currentRunLoop] runUntilDate: [NSDate
>dateWithTimeIntervalSinceNow:0.1]];
>
>
>So the problem has an easy solution that doesn't require hacking out
>menu validation at all...
Thanks- that's exactly what I needed. For the archives, the complete loop looks like:
NSModalSession session = [NSApp beginModalSessionForWindow:window];
for (;;) {
if ([NSApp runModalSession:session] != NSRunContinuesResponse)
break;
// magic which allows web stuff through?
[[NSRunLoop currentRunLoop] runUntilDate:
[NSDate dateWithTimeIntervalSinceNow:0.1]];
}
[NSApp endModalSession:session];
Thanks
Jeffrey Johnson
Macintosh Development
Wavefunction, Inc.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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