How to tell which popups are currently open on Perspective page

Currently I am trying to implement an array of help buttons (each with their own unique respective popup associated with them) in my Perspective session that have the following behavior:

  • When a button is clicked, it opens the button's associated popup.
  • If its associated popup is already open, it closes the popup.
  • If a popup not associated with the button is already open, it closes that popup and opens the popup associated with the button.

To get this behavior, I've been trying to implement code into each of the module buttons that follows this basic control structure:

  1. When one of the module buttons is clicked:
    a. If there is a popup already open on the screen:
    i. Close it.
    b. If the popup was not the popup associated with the button:
    i. Open the popup associated with the button.

That's why I want to know if there is a reliable way to retrieve the data of opened popups within a session/page: the control structure I had in mind is based on the presence of popups on the page and the data associated with them.

I don't believe there is any way to get a list of the active popups in a perspective session.

The next best approach I can think of is to assign a known Id to the specific popup when you open it (this can be done with system.perspective.openPopup).

As part of your script on your button, call system.perspective.closePopup on all the other known popup Ids before opening the new popup.

If you do it correctly, your button script could actually be a single line call to a project library script, where you pass the path to the popup you want to open, its Id, and the Id's of the popups that you want to close.

1 Like

You could keep track of the open popup ids in a session custom property (array type) and add and remove them as they open and close. It sounds like a bit of bother.

A much simpler method would be to make the popup background dismissible.

Another option, if you need to leave the popup open while working on the main view, is to open and close a docked view (as set in the Page Configuration dialogs). I've never tried it.

I would tend in the direction of non-quirky GUI. Make it behave as users are used to on Windows / MacOS / Android, etc.

It sounds like you only want a single popup opened at one time, if that's that case then use the same ID for all popups, then the function will handle closing the appropriate popup if it's opened.

Interesting, this might work. I think I might use togglePopup instead of openPopup, because in the event that the user clicks the button associated with an already open popup, I want the popup to close.

That sounds confusing, unless the button state changes to show its status.