Re: NSPanel not receiving events.
Re: NSPanel not receiving events.
- Subject: Re: NSPanel not receiving events.
- From: Graham Cox <email@hidden>
- Date: Fri, 15 Aug 2008 11:04:21 +1000
On 15 Aug 2008, at 8:42 am, David Springer wrote:
Well, no it isn't. What I want to do is put up this panel (the button
is "Cancel") then go off and do a lengthy http request. This all has
to look like a synchronous operation to the calling code (legacy
reasons). So I do have a reason to want to service events outside of
the "normal" event loop, even though it might be a very good one.
Arrrg.
This really doesn't work. I think what you're saying is that you want
to do something like:
- (BOOL) showADialogUntilTheUserResponds;
and then call this from some code, wait for it to return and then
continue, making use of the response. But while that function is
running it keeps the event loop going so your processing gets driven.
Cocoa's architecture doesn't fit very well with this approach, though
it's possible in limited and user non-friendly situations, like a very
modal dialog that locks out all other UI. However, it's usually pretty
easy to to rearrange your code to avoid it (even legacy code that's
being ported).
The very modal approach is to use [NSApp runModalForWindow:...] or
[NSApp runModalSession:...] which would allow you to do the above if
you really have to. It locks everything out except the window being
run, but keeps the event loop running. Your users won't thank you but
at least it's a simple solution. But for very little extra work, you
can refactor the code to run the window modelessly or document modally
(sheet) and get it to call a response method when it finishes. While
it's displayed the normal event loop continues to run allowing your
processing code to do its thing, but also, allows the user to do other
things if they want. The body of your processing can be run using a
timer or thread.
hth,
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