How to restrict the mouse operation within popup window

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)

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:

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.

2 Likes

@pturmel and @nminchin

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

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

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

@nminchin
Thank you. It works.

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.

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

2 Likes