Non-blocking custom event loop?
Non-blocking custom event loop?
- Subject: Non-blocking custom event loop?
- From: Daniel Furrer <email@hidden>
- Date: Mon, 3 Aug 2009 17:30:02 +0200
I have my own event-loop where I call nextEventMatchingMask: repeatedly.
Many examples I found just pass a untilDate of [NSDate distantPast] to get
this behaviour as stated in the documentation but this doesn't seem to work
for me - even in a very simple setting.
Can anyone see what's wrong?
int main(int argc, char **args){
NSRect frame = NSMakeRect(100, 100, 500, 400);
NSApplication *application = [NSApplication sharedApplication];
NSWindow* window = [[NSWindow alloc] initWithContentRect:frame
styleMask:NSBorderlessWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:NO];
// Start the main event loop:
[application finishLaunching];
while(true) {
NSEvent *event;
while ( event =
[application
nextEventMatchingMask:NSAnyEventMask
untilDate: [NSDate distantPast] // nil
inMode:NSDefaultRunLoopMode
dequeue:YES] )
{
NSLog(@"Event: %@", (id)event);
[application sendEvent:event];
[application updateWindows];
}
}
return 0;
}
_______________________________________________
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