1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Better AU keypress forwarding in Ableton Live.

This commit is contained in:
jules 2013-02-03 11:55:13 +00:00
parent f3d9c3ebe0
commit 70ab8a2e8b

View file

@ -1023,6 +1023,30 @@ public:
}
}
bool keyPressed (const KeyPress&)
{
if (PluginHostType().isAbletonLive())
{
static NSTimeInterval lastEventTime = 0; // check we're not recursively sending the same event
NSTimeInterval eventTime = [[NSApp currentEvent] timestamp];
if (lastEventTime != eventTime)
{
lastEventTime = eventTime;
NSView* view = (NSView*) getWindowHandle();
NSView* hostView = [view superview];
NSWindow* hostWindow = [hostView window];
[hostWindow makeFirstResponder: hostView];
[hostView keyDown: [NSApp currentEvent]];
[hostWindow makeFirstResponder: view];
}
}
return false;
}
//==============================================================================
struct JuceUIViewClass : public ObjCClass <NSView>
{
@ -1383,10 +1407,12 @@ private:
// If we have an unused keypress, move the key-focus to a host window
// and re-inject the event..
static NSTimeInterval lastEventTime = 0; // check we're not recursively sending the same event
NSTimeInterval eventTime = [[NSApp currentEvent] timestamp];
if (lastEventTime != [[NSApp currentEvent] timestamp])
if (lastEventTime != eventTime)
{
lastEventTime = [[NSApp currentEvent] timestamp];
lastEventTime = eventTime;
[[hostWindow parentWindow] makeKeyWindow];
[NSApp postEvent: [NSApp currentEvent] atStart: YES];
}