forwarding key events to cocoa plugin views
forwarding key events to cocoa plugin views
- Subject: forwarding key events to cocoa plugin views
- From: Paul Davis <email@hidden>
- Date: Wed, 19 May 2010 22:13:55 -0400
there were some questions a while back about forwarding key events to AU plugin views. i thought i'd just share the technique i came up with today for working with Cocoa views, in case anyone can benefit from it.
the first point is that its probably infeasible to *both* pass key events to the plugin view *and* have the host interpret them too. Unless the host uses hardly any keys, and in particular, no keys that the plugin view might want to consume, this just doesn't make any logical sense at all. You end up in a nonsense land where its never clever what the next key press might mean, and to whom.
so, the first thing, which ardour already had for non-AU plugins, was a keyboard focus button in the plugin view *window*. when engaged, it implies that all keyboard events received by that window should be sent to the plugin view and not be interpreted by the host. it simply controls a boolean value.
second step: in thet key event handler for the plugin view *window*, if the keyboard focus variable is true, we pass the event to a function that does this:
[[[au_view window] firstResponder] keyDown:event]
au_view : the cocoa view obtained from the plugin view component
event: an NSEvent
obviously, keyDown, keyUp or FlagsChanged will need to be used depending on the value of [event type]
from my testing with a handful of cocoa-view using plugins, this seems to work quite well. you get keyView navigation (tab, etc to move from keyView to keyView), which makes it possible to operate any of the Apple plugin cocoa views with just the keyboard. the user can either click with the mouse in the desired view to make it the keyView, or can just press tab etc. to navigate around the view.
i hope this might be useful to the handful of host authors out there who have wondered about this. i'm not sure i will bother with finding the equivalent Carbon method for this.
--p
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden