Browse Source

Better AU keypress forwarding in Ableton Live.

tags/2021-05-28
jules 12 years ago
parent
commit
70ab8a2e8b
1 changed files with 28 additions and 2 deletions
  1. +28
    -2
      modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm

+ 28
- 2
modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm 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];
}


Loading…
Cancel
Save