Getting Carbon events in Cocoa
Getting Carbon events in Cocoa
- Subject: Getting Carbon events in Cocoa
- From: "Tom Harrington" <email@hidden>
- Date: Thu, 30 Mar 2006 10:13:06 -0700
I'm trying to receive some Carbon events in an app that's otherwise
mostly Cocoa, but they're not all coming through as I'd expect. I'm
using the following to register for the events:
EventTypeSpec eventSpec[4] = {
{ kEventClassKeyboard, kEventRawKeyModifiersChanged },
{ kEventClassKeyboard, kEventRawKeyDown },
{ kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDown }
};
InstallEventHandler(GetEventMonitorTarget(),
MonitorHandler,
(sizeof(eventSpec) /
sizeof(EventTypeSpec)),
eventSpec, nil, nil);
I'm getting the mouse events, no trouble there. But the keyboard
events don't show up unless I follow the above with a call the Carbon
RunApplicationEventLoop(). However that's awkward because (a) it
installs its own "quit" handler, and (b) it does not return.
How can I get these keyboard events in an app with a Cocoa event loop running?
[And in case anyone's wondering, I'm using Carbon here because Cocoa
doesn't appear to have an equivalent to GetEventMonitorTarget().
Using NSEvent doesn't cut it here because it won't receive the events
unless my app is in the foreground, while GetEventMonitorTarget() will
receive the events at all times.]
--
Tom Harrington
email@hidden
AIM: atomicbird1
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden