ApplicationCommandManager & MenuBarComp multi-window problem


I’m creating an application with undo/redo and application commands. I have a piano roll editor in a DocumentWindow which is separate from the main window which contains a MenuBarComponent which shows in its edit menu the commands for the currently focused ApplicationCommandTarget. Problem is that when I click the menu, the focus gets stolen from the Piano Roll Component which is located in the separate window… What happens is that the menu, which is located in the main window (so not the piano roll window!), will get the focus, and so the application commands in the edit menu will be greyed out.
I tracked this down to WM_KILLFOCUS in the Windows Component Peer. I have no clue how to handle this - the Piano Roll should actually keep the focus, or at least regain it back before the MenuBarComponent gets updated.