DialogWindow lanuchAsync and mouseEvents outside the window


#1

I have a DialogWindow that holds my component (a coulour selector with a button), i launch the DialogWindow using launchAsync() (as suggested in the manual), i'd like to dismiss the window when a mouse click occurs outside the shown window, i can't register Desktop::getInstance().addGlobalMouseListener(this); in my component (it does not receive any mouse events) so i don't know when to exitModalState() within the component.

What is the correct way to achieve this behavior ?


#2

 

Component::inputAttemptWhenModal()   ?

 


#3

Well i tried that, witch component should have that callback implemented ? Alo i can't assume that the click outside the modal window will occur on ANY of my components, it might occur on the desktop or on some other application. I just need to know it occured.


#4

Well i spent a lot of time today on that and got no solutions. Is that even possible ? How does the PopupMenu do it ? do i need to pass some special flags to the Window to receive mouse events outside it's boundries ?


#5

The PopupMenu uses inputAttemptWhenModal, but if you can't make it modal, you could probably do it by using a FocusChangeListener and a timer that checks Process::isForegroundProcess to see whether another app has been selected.