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 (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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to