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:
parent
f3d9c3ebe0
commit
70ab8a2e8b
1 changed files with 28 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue