Hi there,
I’m working on a audio application written in C++ (or Qt to be more specific), and recently I started working on VST/AU plugin support. I intend to use JUCE to scan the available plugins, show the plugin editor, as well as process audio for the plugins.
So far I was able to find plugins in the users systems, create plugin instances for them, and show their editors.
A bit more details about how I’m currently showing the editor:
- Creating a
AudioPluginInstance
using aPluginDescription
- Then creating a
AudioProcessorEditor
usingAudioPluginInstance::createEditorIfNeeded()
- Then show the editor using
AudioProcessorEditor::addToDesktop()
It seems to work well for both VST3 and AU plugins so far.
However, if I enable the “close” button for the plugin editor window (i.e. via ComponentPeer::StyleFlags::windowHasCloseButton
), even though the “close” button is shown on the title bar of the editor window, it doesn’t do any thing (e.g. it doesn’t actually close the editor window when clicked). I’m also hitting an assertion failing at juce_Component.cpp:821
:
void Component::userTriedToCloseWindow()
{
/* This means that the user's trying to get rid of your window with the 'close window' system
menu option (on windows) or possibly the task manager - you should really handle this
and delete or hide your component in an appropriate way.
If you want to ignore the event and don't want to trigger this assertion, just override
this method and do nothing.
*/
jassertfalse;
}
I’m looking for advice on the best way to handle the “close” button of an editor window in a host application.
Some options I can think of:
- Manage the editor window in my own code, and pass the window handle when calling
AudioProcessorEditor::addToDesktop()
- I think this might be the way to go, but this may involve extra work like properly resizing the editor window before showing it or when the plugin editor changes size
- Somehow “inject” code into the chain of functions that eventually calls
userTriedToCloseWindow()
, and perform the window close- This feels a bit hacky, but I think this might be the only thing needed in my particular case
- I tried to find an existing overriding point for this (e.g.
ComponentListener
), but couldn’t find any
Cheers.