Toggling between popups

Hi, I have a popup that opens whenever I right click on a valve. These valves are displayed on my view as embedded views. By passing a different identifier to each embedded view, it is possible to open multiples popups. However, I want to be able to toggle between these popups, as the following sequence describes: Right click on the first valve, and the popup opens. Then right click on another valve, and have that popup to close, and open a new one.

Using the toggle tool and giving each valve the same identifier helps, but two clicks are needed in order to have the popup toggle at all, since the first one closes the first popup, and the second one opens the new one.

I could use some help! Thanks in advance,

Gabriel.

you could use system.perspective.sendMessage() and have the popup listen for it and call system.perspective.closePopup() when it receives the message. If you put the sendMessage before opening the new popup in the right-click script all the existing popups with the listener should close.

Thanks for your reply.

That implementation worked perfectly. The only question I have, is to why this does not work when the identifier of the popup is unique. Is it that the popup action runs before the script finishing?

Thanks again.