Pressing escape doesn't close the plugin window for VST on Mac, but does for AudioUnit


#1

Hello! I’m working on a plugin that has an AU version and a VST version, and with the Audio unit, the plugin window closes when the escape key is pressed, but with the VST it doesn’t. At first I thought it might be because forwardCurrentKeyEventToHostVST in juce_VST_Wrapper.mm doesn’t really do much for 64 bit plugins, but after reading around a bit on here, it sounds like it should be automatically forwarding key events on because that function returns false.
However I added an else onto the function as follows

bool forwardCurrentKeyEventToHostVST (Component* comp, bool isNSView)
{
#if ! JUCE_64BIT
if (! isNSView)
{
NSWindow* win = [(NSView*) comp->getWindowHandle() window];
[[win parentWindow] makeKeyWindow];
repostCurrentNSEvent();
return true;
}
#else
NSView* view = (NSView*) comp->getWindowHandle();
NSView* hostView = [view superview];
NSWindow* hostWindow = [hostView window];

[hostWindow makeFirstResponder: hostView];
[hostView keyDown: [NSApp currentEvent]];
[hostWindow makeFirstResponder: view];
return true;
#endif
``
ignoreUnused (comp, isNSView);
return false;
}

This passes on the key presses manually, and now pressing escape does what it’s meant to (closes the plugin window). Are there any risks around adding this else clause in? Should I just go ahead with this change? Otherwise does anyone have any ideas why the key events aren’t getting passed along in the first place?