# Returning a value from a window; waiting for window close

**URL:** <https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517>\
**Category:** Ignition\
**Created:** [June 4, 2014, 4:56am UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517 "2014-06-04T04:56:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjcampbell76](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@jjcampbell76](https://forum.inductiveautomation.com/u/jjcampbell76)\
**Post date:** [June 4, 2014, 4:56am UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/1 "2014-06-04T04:56:12Z")

</div>

I’ve been looking for some way to pull off similar behavior to system.gui.showNumericKeypad(). To be specific, I want to be able to call my method within a script and have it (safely) block until the user either ok’s or cancels from the input window.  
Understanding the caveats (and no-no’s) in blocking the UI thread, etc I’ve done my best to try to work around it to no avail. I have managed to brick my gateway a few times with runaway loops which has been frustrating. This said, my attempt has been implemented as a script module. The method opens my GUI then attempts to wait until it is closed. This is the catch-22… If I loop within the script it blocks the UI thread and I brick. Yielding time doesn’t do anything (e.g. time.sleep(0)) since I am on the same execution thread so I cannot yield time in such a way that the window and UI continue to function. Using invokeLater() and invokeAsynchronous() seem to be useless… The latter since putting the polling loop there does not effectively block my method from returning.  
So am I hosed? Is there a sanctioned/safe way to open what amounts to a modal dialog window that will block in the same manner as showNumericKeypad() does?! Thanks in advance!

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [June 4, 2014, 1:55pm UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/2 "2014-06-04T13:55:59Z")

</div>

I think the best thing you could try is to show a hidden container that blanks out your window (add an Event Handler that sets the [mouseClick](http://inductiveautomation.com/support/usermanuals/ignition/event_types.htm#mouse) event to simply pass) then show a new container that replicates the functionality of the NumericKeypad or other wise.

Make sure the hidden container has a higher Z-order than your other components and that your new container has a higher Z-order than the hidden one. Let me know if you need more clarification.

---

<div class="post-metadata">

**Author:** ![jjcampbell76](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@jjcampbell76](https://forum.inductiveautomation.com/u/jjcampbell76)\
**Post date:** [June 13, 2014, 2:45am UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/3 "2014-06-13T02:45:59Z")

</div>

No ideas on this one? Figured there has to be some way to do this without a bunch of hoop-jumping… Want to make a call, get blocking GUI to force user response, return result, continue execution… No takers?!

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 13, 2014, 7:16pm UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/4 "2014-06-13T19:16:48Z")

</div>

Here’s a blast from the past (FPMI days) that should work for you…

[http://inductiveautomation.com/forum/viewtopic.php?f=23&t=3431](http://inductiveautomation.com/forum/viewtopic.php?f=23&t=3431)

---

<div class="post-metadata">

**Author:** ![jjcampbell76](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@jjcampbell76](https://forum.inductiveautomation.com/u/jjcampbell76)\
**Post date:** [June 13, 2014, 8:37pm UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/5 "2014-06-13T20:37:49Z")

</div>

Jordan,

Thanks for the link, but it appears that solution still does not block in the way showNumericKeypad() does. That is the core of what I need – to throw my call into the middle of a script and have it sit there waiting for the return value before it continues executing.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 16, 2014, 9:54am UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/6 "2014-06-16T09:54:57Z")

</div>

Perhaps a shift in thinking is required here. Why not split your script into two separate scripts? The first part preps the data and opens the (parametrized) window. The second is called by the OK button in your window.

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [June 16, 2014, 12:49pm UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/7 "2014-06-16T12:49:35Z")

</div>

It seems to me that the solution that adamaustin solves the problem. What is it about his solution that does not fit your need?

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [June 16, 2014, 9:44pm UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/8 "2014-06-16T21:44:00Z")

</div>

Here is a window that covers the current main window, and accepts some text input. You can modify to suit.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [June 16, 2014, 9:50pm UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/9 "2014-06-16T21:50:07Z")

</div>

If you need to block to a docked window as well, place a rectangle over the whole window, and make it non opaque/remove the border. Inside of the mouseClicked event on that rectangle, just put the following:

```auto
pass
```

Then synchronize the visibility of that window with your input window.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [June 16, 2014, 10:04pm UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/10 "2014-06-16T22:04:08Z")

</div>

So something like these windows.

---

<div class="post-metadata">

**Author:** ![camatt3](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@camatt3](https://forum.inductiveautomation.com/u/camatt3)\
**Post date:** [September 29, 2017, 5:53am UTC](https://forum.inductiveautomation.com/t/returning-a-value-from-a-window-waiting-for-window-close/8517/11 "2017-09-29T05:53:59Z")

</div>

For anyone still looking for a solution, check out my post in [this thread](http://forum.inductiveautomation.com/t/modal-windows/651/8).
