I tried this:
void PluginEditor::globalFocusChanged(Component* focusedComponent)
if(focusedComponent && myOtherWindow)
auto * parent = focusedComponent->getTopLevelComponent();
if(parent && (parent == myOtherWindow->getTopLevelComponent() || parent == getTopLevelComponent()))
I figured comparing the top level components would make it work even when a sub-component like a button gains focus.
But it does not fully work. In Maschine, if I am tuning a parameter in my plugin, then click on another track, then click back on this track, my other window is correctly brought to front.
But if my plugin didn’t have the focus before changing tracks, it won’t gain it back when clicking on its track. Despite having checked the option “Plugin Editor requires Keyboard Focus” in the Projucer.
It looks like changing tracks doesn’t necessarily give the focus to the track’s opened VST, despite making it go to the front.