# How to prevent user from closing pop up window until neccessary action has been taken

**URL:** <https://forum.inductiveautomation.com/t/how-to-prevent-user-from-closing-pop-up-window-until-neccessary-action-has-been-taken/62129>\
**Category:** Ignition\
**Created:** [July 20, 2022, 3:12pm UTC](https://forum.inductiveautomation.com/t/how-to-prevent-user-from-closing-pop-up-window-until-neccessary-action-has-been-taken/62129 "2022-07-20T15:12:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahman.tarek](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@rahman.tarek](https://forum.inductiveautomation.com/u/rahman.tarek)\
**Post date:** [July 20, 2022, 3:12pm UTC](https://forum.inductiveautomation.com/t/how-to-prevent-user-from-closing-pop-up-window-until-neccessary-action-has-been-taken/62129/1 "2022-07-20T15:12:40Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6cf387af81351b7916af49870795e523877b42f.png)  
hello guys,  
I have a use case where when an alarm is triggered a pop up window appears (see image). I want the user to enter a comment in the comment box shown and select a reason for the alarm from the drop down before he can close the popup.

How do I prevent the user from closing the popup window if either the comment box has not been filled or dropdown has not been selected? would this be a script in the ‘visionwindowclosed’ section? Thanks

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 20, 2022, 3:44pm UTC](https://forum.inductiveautomation.com/t/how-to-prevent-user-from-closing-pop-up-window-until-neccessary-action-has-been-taken/62129/2 "2022-07-20T15:44:10Z")

</div>

How is the user initiating the close of the window? With the Button?

If it is in the button then just test for your requirements in the `ActionPerformed` event of the button.

```auto
comment = event.source.parent.getComponent("path to comment box").text
reason = event.source.parent.getComponent("path to reason dropdown").selectedValue

if len(comment) > 0 and reason != -1:
   system.nav.closeWindow("path to popup")
else:
   system.gui.messageBox("You must provide a comment and reason")

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [July 20, 2022, 3:46pm UTC](https://forum.inductiveautomation.com/t/how-to-prevent-user-from-closing-pop-up-window-until-neccessary-action-has-been-taken/62129/3 "2022-07-20T15:46:45Z")

</div>

In addition to this you can bind the enabled property of the button to something like

`len({Root Container.commentBox.text})>0 && {Root Container.dropDownRason.selectedValue}>-1`

I think you may want to uncheck the `Closeable` property on the popup behavior as well -  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/3/5328c3c07eee93b69ffb6a7a10da27485dd0d7a3.png)

This gets rid of the little X in the top right so they can’t just close it that way.
