John,
It seems that you have a fundamental misunderstanding about how events work in Cocoa on Mac OS X. I will do my best to explain to, provide relevant documentation links, and answer your questions as best as possible.
In Mac OS X, events are processed by the application object (the host you are running in), and are dispatched according to the event type. Mouse events go first to the window, and then are dispatched to the view in which the click occurred. Key events go to the first responder of the key window:
Futhermore, key events are processed based on whether the key is a character, a key equivalent, keyboard action, etc. Some events such as command keys are intercepted by the global application object (in your host). Some keys may be intercepted at that level and never reach your plugin because they have special meaning to your host (such as the space key being used to control the hosts' transport). You cannot rely on which command keys are available to your plugin since this behavior is dictated by your host and what key bindings are defined.
Now, this special key-processing caveat aside, key events will get delivered to your plugin view if the window that your view is in has focus. In this case, key events are sent to the first responder of that window. If your view is not the first responder of the window, you will not get any key events.
How does your view become first responder? Any textfields that are in your AudioUnit view will automatically respond correctly. Once they are clicked in, they become first responder, and then key events are delivered directly to them. If you have custom objects that you expect to handle key events, then they need to be a subclass of NSResponder, and need to acceptFirstResponder events by overriding -acceptsFirstResponder and returning YES. Secondly, if you have your own mouseDown: handler, you need to make sure that clicking on your view sets the first responder of the window to your object:
If you do not do these things correctly, you will not receive any key events. I realize this is a lengthly response, but I feel that it is important to answer as completely as possible to avoid any further confusion on this topic. So, the answer to your question is:
A) You (probably) did not code your view right.
Key events work just fine in logic and other hosts, with the caveat that there are some special keys that those hosts may pre-process and may or may not deliver to you. This behavior really is up to the host, and you should not try to circumvent the event system of the host that you are living in.
If you have any further questions on this topic, I would be more than happy to answer!
Best of luck to your in your plugin development.
-michael On May 25, 2010, at 6:31 AM, john smith wrote: >So, we seem to have settled that Logic and AULab is not passing on the keyboard events to the plug-ins.
>i'm not sure we've "settled" this at all. i would be very, very suprised if you can't get logic (at least) to forward key events to a plugin view.
If we havn't settled on this, then my original question remains, I'm afraid: How do I receive keyboard input from Logic? Currently my breakpoints are not triggered, which means that A: I didn't code it right or B: I have to change some Logic setting or something like that or C: Logic does not support keyboard input in the plug-ins Thanks, Michael Olsen
|