"Nested" runloops
"Nested" runloops
- Subject: "Nested" runloops
- From: Eric Matecki <email@hidden>
- Date: Wed, 20 Jul 2011 15:01:35 +0200
Hello,
I have to port a software to take advantage of 64 bits adressing.
The software was originally written for Windows...
So there isn't any real runloop, but there are GetMsg() function calls
spread all around the source code (in about 200 files out of the 1000+ !!).
In Carbon, I used the trick described in Q&A 1061.
(http://developer.apple.com/qa/qa2001/qa1061.html seems dead)
It sent an 'artificial' event to itself, started the mainrunloop,
caught the event and from there on used ReceiveNextEvent() to get and process
the message. This ensured all default event handlers where installed.
Now I want to do something more or less like that in Cocoa,
because there is no (reasonable) way the software can be modified to use a runloop.
There is also no NIB file, as we do all our GUI stuff ourself.
We just open a window and draw inside !
So here is what I have tested :
I create a NSWindow and put a subclass of NSOpenGLView as contentView:
In that view I override all event processing methods, "decode" the event
into our own event structure, and append it to our event queue.
In this 'append to queue' method, after appending the event, if it is the first time it is called,
I call the working function of the software, which will call GetMsg() from everywhere.
GetMsg(), if our event queue is empty, tries to get new 'native' events and decodes and append them to the queue.
Thats where my problems really start.
I tried all of these :
NSRunLoop* runloop = [NSRunLoop currentRunLoop];
assert(runloop);
[runloop acceptInputForMode: NSModalPanelRunLoopMode beforeDate: [NSDate dateWithTimeIntervalSinceNow: 1];
// [runloop acceptInputForMode: NSDefaultRunLoopMode beforeDate: [NSDate dateWithTimeIntervalSinceNow: 1]];
// [runloop runMode: NSDefaultRunLoopMode beforeDate: [NSDate dateWithTimeIntervalSinceNow: 1]];
// [runloop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1]];
The 'timeout' of 1 second is so I have time to read the traces in the console.
What happens is:
- when I do nothing with the window, the timeout 'fires' and GetMsg() returns nil after one second.
- when I 'draw' with the mouse (down,drag,up), the method I call on runloop returns
(almost) instantly, thus the event has been processed somehow, but the event methods
in my view AREN'T called !!
Anything I'm doing wrong ? (beside the fact I really should be using the runloop
as it was meant to, but can't ...)
Thanks for your help.
Eric M.
--
Keep intel OUTSIDE my Mac !
Hiii !!! I can see Intel chips creeping around my G5 !
Eric M.
_______________________________________________
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