Returning a value from a window; waiting for window close

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!

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 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.

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?!

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

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

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.

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.

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

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

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:

pass

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

So something like these windows.

For anyone still looking for a solution, check out my post in this thread.