Switch between Modal screens with One Tap?

I've set up two modal popups that lay directly on top of one another. I have buttons down the side to choose between modal popups. When I tap the "modal 2" button, it closes the "modal 1" popup being displayed (since it's outside the modal window), but in order to get the "modal 2" popup to display, I have to tap it again to open it.

Is there a way to have the button both close "modal 1" popup and open "modal 2" popup and vice versa with only one tap?

UPDATE: Well, I had a great solution that switched between the modal popups as desired, but unfortunately it required me to make the interaction 'false' and none of the buttons worked. I am such a newb.

UPDATE 2: Since I'm not well enough versed in coding to figure the problem out (or even follow the suggestion given) I decided to change tactics and created three tabs instead, hid the tabs, and made buttons to switch between them. This actually works beautifully. Thanks for your help.

Hi, i think you could script that in a custom module, when you close a modal with name "xyz" you can catch that in OSCOUTFILTER(assuming "xxx" is the id of the modal you want to open).

if (address === '/xyz' && args[1].value === 0){ //0 is sent when closing
receive('/xxx',1)

and of course the same with address is xxx ...

hope this works i don't tried this.

Is there a script to turn the modal interaction on and off? If I can incorporate that into my previous button script: (set 'modal_1', 0) etc. (which worked when interaction was false), I could tell the button to make interaction false, make the switch, then turn interaction true again. Does that make sense?

yes, you have a property for that, you can set this property to true or false (0/1 works too).
It is working different than setting a value for a widget(have a look at the documentation/forum i do this via a custom module)

1 Like

Thank you for your kind help. I've come up with another solution using tabs instead of modals, which seems more straightforward.