Clicking outside component

So I’ve got this little typeahead editor component. And I’d like the window showing the options menu to disappear when the user clicks outside of the TextEditor or ListBox, and/or maybe if the application loses focus.

Any ideas how to detect that?

Hold that thought - just looking at the CalloutBox code…

Is there a reason this function isn’t exposed in the API?
juce_areThereAnyAlwaysOnTopWindows()

Also - I’ve got dismissing when the application doesn’t have focus. I can dismiss when keyboard focus moves. But how do I detect the user clicking outside the bounds of my component? Do I have to be modal for that? And if I am modal how do I pass the mouse event through?

What about being a global mouse listener: http://klangfreund.github.io/jucedoc/doc/classDesktop.html#add528b1597a432f2e4cb9b10314fc210?

2 Likes

Yep. That works :slight_smile: