Re: Receiving user events from within an NSTimer callback
Re: Receiving user events from within an NSTimer callback
- Subject: Re: Receiving user events from within an NSTimer callback
- From: Quincey Morris <email@hidden>
- Date: Thu, 22 Jan 2009 16:34:07 -0800
On Jan 22, 2009, at 14:55, John Mikros wrote:
I'm working on a Cocoa application which does all of its work within
an NSTimer callback that is called regularly. Events are handled
normally within a Cocoa run loop.
However, there are times when within the callback, the code enters
an inner loop, and will not exit until some user action is performed.
I'm trying to force the run loop to pump events within this inner
loop, but I can't seem to ever get it to work.
I use, from the timer callback:
NSEvent *event;
while (event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate: nil inMode: NSEventTrackingRunLoopMode dequeue: YES])
[NSApp sendEvent: event];
I don't know if this is officially blessed or not, but it certainly
seems to work just fine.
In the places I've done this, I was only really interested in making
the mouse and keyboard work, hence NSEventTrackingRunLoopMode. You
could use the default run loop mode instead, I guess.
_______________________________________________
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