Keyboard handling in Live on OS X 10.8

Hi all,

I have a plug-in that is not interested in keyboard events and wants them passed on to the host. This works fine in versions of OS X up to 10.7.x. However, in OS X 10.8, they plug-in swallows the event.

Here is what I have been able to find out. In EditorCompHolder::keyPressed, on 10.8, the window returned on this line:

is actually an NSPanel, not an NSWindow. On 10.7 and 10.6 it is an NSWindow. Key presses are not being forwarded because NSPanel does not allow you to set the first responder using makeFirstResponder.

I’ve tried getting the parent window of the NSPanel (doesn’t help), sending the event to the main application window (forwards the event back to the plug-in, resulting in an infinite loop) and some other things. Nothing has worked.

Has anyone successfully solved the problem?
Thanks.

I found that this works:

[hostWindow orderOut: nil];
[hostWindow orderFront: nil];
[hostView keyDown: [NSApp currentEvent]];
[hostView keyDown: [NSApp currentEvent]];

Note that calling hostView keyDown twice is necessary - the first keyDown gets swallowed. Having to call keyDown twice is a little worrying. Also, this makes the whole plug-in window lose focus. I’d be interested to hear if anyone finds a better solution.