# How to restrict the mouse operation within popup window

**URL:** <https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794>\
**Category:** Ignition\
**Created:** [August 27, 2019, 11:57am UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794 "2019-08-27T11:57:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawei.liu](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dawei.liu](https://forum.inductiveautomation.com/u/dawei.liu)\
**Post date:** [August 27, 2019, 11:57am UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/1 "2019-08-27T11:57:20Z")

</div>

Hi,

I have a window with some buttons in it. When clicking one button, it will pop out a popup window. The focus will be switched to the pop out window, but we still can move the cursor outside the popup window and do other operation. So is there any method that can restrict the the mouse operation within popup window?

( means that we shall do some response work in the popup window, after the popup window disappear, then we can do other operation）

 ![png1](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/b40d2fc9f52e34eff9fa3c660c2fa631be6f5420.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 27, 2019, 12:26pm UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/2 "2019-08-27T12:26:22Z")

</div>

The behavior you are describing is generically called a _ **modal** _ window. (By generically, I mean across all GUI programming platforms, not solely Ignition.) Unfortunately, Ignition's architecture makes this rather difficult to implement. This thread has the most comprehensive options for you:

> [@Modal Pop-Up How-To?](http://forum.inductiveautomation.com/t/modal-pop-up-how-to/15211/10):
>
> Alright, who is ready for some hacking? This might get complicated, but here is how I have achieved this in the past. As an example, I will use my custom lock screen, attached in this post. Here is the script. def lockScreen(): from javax.swing import SwingUtilities,JFrame #Import some stuff import system.nav if system.util.getGlobals().has\_key('lockScreen'): #Check if the screen has been locked before. This really just saves the set up code system.util.getGlobals()["app"].getRootPane…

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 27, 2019, 1:23pm UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/3 "2019-08-27T13:23:02Z")

</div>

The way that I implement this is by having a boolean client tag called something like `ModalPopupShown`. Then on every page, including the navigation bar, I have a rectangle with transparent grey as big as the window with a mouse clicked event set to simply 1 so that the mouse cannot click beneath it, but that does nothing itself. This should have a visible expression that uses the client tag. Then, for any popups you want modal, simply write a 1 to the client tag. Make sure to anchor the rectangle to all four window sides.

---

<div class="post-metadata">

**Author:** ![dawei.liu](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dawei.liu](https://forum.inductiveautomation.com/u/dawei.liu)\
**Post date:** [August 27, 2019, 3:27pm UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/4 "2019-08-27T15:27:32Z")

</div>

@pturmel and @nminchin

Thank you very much for help. I will try with your suggestions.

---

<div class="post-metadata">

**Author:** ![Min.Liao](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Min.Liao](https://forum.inductiveautomation.com/u/Min.Liao)\
**Post date:** [August 30, 2019, 7:59am UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/5 "2019-08-30T07:59:46Z")

</div>

Hi,how can I make a rectangle with transparent gray? I find that all the components have no property of transparency.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 30, 2019, 8:27am UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/6 "2019-08-30T08:27:59Z")

</div>

Colours have an alpha component to them. Set this to less than 100 to make any colour be transparent.

---

<div class="post-metadata">

**Author:** ![Min.Liao](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Min.Liao](https://forum.inductiveautomation.com/u/Min.Liao)\
**Post date:** [August 30, 2019, 8:48am UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/7 "2019-08-30T08:48:53Z")

</div>

@nminchin  
Thank you. It works.

---

<div class="post-metadata">

**Author:** ![dwoo](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@dwoo](https://forum.inductiveautomation.com/u/dwoo)\
**Post date:** [July 7, 2023, 5:46pm UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/8 "2023-07-07T17:46:47Z")

</div>

I've tried this in 8.1.24 and when I click on the "back" window with the rectangle it still allows it and the popup is hidden. I opened the popup using a button's actionPerformed event. The rectangle appears  
when the popup is opened. I've tried using "1" or "pass" in the rectangle's mouse clicked event, even in the mouse pressed and released events.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/2/424bdcac2a6271a2c47adebccf55fcfaaa6ed9a8.png)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [July 7, 2023, 11:23pm UTC](https://forum.inductiveautomation.com/t/how-to-restrict-the-mouse-operation-within-popup-window/27794/9 "2023-07-07T23:23:25Z")

</div>

You need to make sure that the popup is a higher layer to the main window, otherwise focusing the main will put it in front of any other window with the same layer. The layer is set in the window's properties
