# DialogWindow lanuchAsync and mouseEvents outside the window

**URL:** <https://forum.juce.com/t/dialogwindow-lanuchasync-and-mouseevents-outside-the-window/11500>\
**Category:** General JUCE discussion\
**Created:** [September 18, 2013, 4:15pm UTC](https://forum.juce.com/t/dialogwindow-lanuchasync-and-mouseevents-outside-the-window/11500 "2013-09-18T16:15:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [September 18, 2013, 4:15pm UTC](https://forum.juce.com/t/dialogwindow-lanuchasync-and-mouseevents-outside-the-window/11500/1 "2013-09-18T16:15:19Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![hugh](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@hugh](https://forum.juce.com/u/hugh)\
**Post date:** [September 19, 2013, 2:41am UTC](https://forum.juce.com/t/dialogwindow-lanuchasync-and-mouseevents-outside-the-window/11500/2 "2013-09-19T02:41:58Z")

</div>

&nbsp;

Component::inputAttemptWhenModal()&nbsp;&nbsp; ?

&nbsp;

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [September 19, 2013, 7:04am UTC](https://forum.juce.com/t/dialogwindow-lanuchasync-and-mouseevents-outside-the-window/11500/3 "2013-09-19T07:04:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [September 19, 2013, 7:19pm UTC](https://forum.juce.com/t/dialogwindow-lanuchasync-and-mouseevents-outside-the-window/11500/4 "2013-09-19T19:19:04Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 19, 2013, 7:50pm UTC](https://forum.juce.com/t/dialogwindow-lanuchasync-and-mouseevents-outside-the-window/11500/5 "2013-09-19T19:50:54Z")

</div>

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