Re: Installing carbon event handlers into a cocoa application
Re: Installing carbon event handlers into a cocoa application
- Subject: Re: Installing carbon event handlers into a cocoa application
- From: Eric Schlegel <email@hidden>
- Date: Sun, 12 Nov 2006 10:58:04 -0800
On Nov 12, 2006, at 9:08 AM, Justin Walsh wrote:
I created a simple cocoa application and am able to get the
windowRef and
pass it to my class. From there it is finding the window, and
installing
the event handlers without returning any errors. However in the cocoa
application, it is not showing any response.
AppKit (inside [NSApplication sendEvent:], I think) is dispatching the
event via the AppKit event-dispatching mechanism. This mechanism is
entirely separate from the Carbon event dispatching path - the AppKit
path goes through NSResponder subclasses instead of Carbon event
handlers. That's why your event handlers aren't being called.
I started to look into subclassing the NSApplication class, and
think this
is where the solution is. My guess is that cocoa is absorbing the
keyboard
and mouse events, because by default it also creates event handlers
for
these actions.
That's true, although I don't think subclassing NSApplication is
really going to get you what you want; you can't cause the Carbon
event handlers to be called by somehow preventing NSApplication from
dispatching the event, because there's simply no code running by
default in a Cocoa-based app that will dispatch Carbon events.
One thing you _could_ do is to create your window using the Carbon
APIs originally, and then wrap it into a Cocoa window with [NSWindow
initWithWindowRef]. In this case, AppKit will dispatch Carbon events
to the Carbon window since it knows that the window started out life
as a Carbon window.
This means, of course, that you have to deal with this window
basically as a Carbon window, though; you wouldn't be able to use
Cocoa-based views in it, for example.
-eric
_______________________________________________
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