How to catch mouse events outside editor?


#1

Hi,
I have a Plugin that uses some custom menus similar to the juce::PopupMenu, working in a modal way. Now, when the menu is shown and a MouseDown event occurs either within the Editor or completely outside the ComponentPeer of the Editor, the menu is closed as expected. The problem is, when I click on a part of the plugin window provided by the host e.g. the titlebar or the load/save/bypass buttons of the host, the menu won’t get any callback to be closed. This is not the way it’s supposed to work, for example I can move the plugin window and my modal state menu isn’t moved or closed, which isn’t that fancy.

Is there a way to get something like a globalMouseListener that catches mouseDown events even if they are outside the Editor? I tried the Desktop::addGlobalMouseListener approach but with no success. I think a problem is that the plugin frame provided by the host is seen as the Editors Peer, hence no focusLost or something like that works and it’s neither a part of the juce Editor, so no mouse callbacks work.

Any idea for a workarround, because I think a user would expect an open menu to disappear on a mouse click, no matter where this happens.

Thanks
friscokid