Toggle Layers with a button

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

How to I click a button and hide a layer called “page_1” and show a layer called “page_2” and vice versa

What is the expected result

when i click the button “page_1” is hidden
and “page_2” is shown

What is the actual result

“page_1” remains visible, “page_2” remains hidden.
my thought is that the click event is triggered twice when both layers are visible so it goes back to normal but I added trigger once everywhere :thinking:

I can do it a different way but I don’t see why this doesn’t work

Related screenshots

Every event is proccessed in order from top to bottom. So as soon as the top event is hidden, the next event triggers baded off tje fact it is hidden, then the whole cycle begins anew.

What you should do is add a “toggle boolean variable myToggle” action to your first event (doesn’t matter if object/scene/global) then add conditions to the subevents where “MyToggle is false” for the first one and “myToggle is true” for the second. No other conditions are needed on the subevents as the parent event already triggers only kcne

Ok thank you :slight_smile: I have refactored anyway so I have a solution I just want to understand the closure of the events. because this doesn’t work either

like the click seems to still be true even though the 2nd argument has changed from true to false

This was my solution, make it paginated

Your screenshots above have the same issue you would originally. The events will still process sequentially.

You reslly should just use the toggle boolean action and conditio s around a boolean variable.

So far this is best way i found to use same button to switch between on and off state

1 Like