Re: More re: Carbon Events vs Cocoa Events
Re: More re: Carbon Events vs Cocoa Events
- Subject: Re: More re: Carbon Events vs Cocoa Events
- From: Charles Srstka <email@hidden>
- Date: Mon, 1 Apr 2002 15:42:35 -0600
On Monday, April 1, 2002, at 03:28 PM, Ondra Cada wrote:
On Monday, April 1, 2002, at 11:15 , Charles Srstka wrote:
Well, I just tried it, and unfortunately, it doesn't seem to catch all
events. I downloaded the NoisyApp example, and it doesn't seem to log
Apple Events. If I send the AppleScript 'tell application "NoisyApp"
to beep' it will send the message, and it will beep, but NoisyApp will
not log the event. My little Carbon test app will log the event if I
tell it to beep...
Well I *guess* (emphasized since I don't understand AppleScript, it's
not my cup of tea) the problem is caused by the sad fact that
AppleEvent is not an event!
I'm pretty sure that it is. All I did to catch it was add a log in the
Carbon app's event loop like this:
void EventLoop()
{
Boolean gotEvent;
EventRecord event;
gQuitFlag = false;
do
{
gotEvent = WaitNextEvent(everyEvent, &event, kSleepTime, nil);
if (gotEvent) {
printf("what:%i message:%li when:%li where:%i, %i
modifiers:%i\n",
event.what, event.message, event.when, event.where.v,
event.where.h,
event.modifiers);
DoEvent(&event);
}
} while (!gQuitFlag);
ExitToShell();
}
The Event Manager picks up the Apple Events, they go through the event
loop, and get logged by the printf statement. The int 'event.what' is
equal to 23, which is defined as kHighLevelEvent in the Carbon docs.
I'm guessing what's going on with sendEvent: is that it probably doesn't
catch events that are received rather than sent by the application. I
wonder if there's a way to do this in Cocoa. It would be neat if there
were...
If you wanted though to define "event" as "anything which goes from
outside to the application, possibly changing its behaviour", well,
would your little Carbon test log, say, signals properly?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.