Switch tabs with one Button or a Switch

Hello,

Is it possible to toogle between all my tabs with just one Switch or 2 Buttons?
Unfortunately I do not find anything about it.
It would be great if someone could help me :slight_smile:
Thanks

Hey man,

How did you create tabs?

I couldn't find the "tab" wedgit anywhere :sob:

You can create a Tab in a panel. You can right click on your panel in the tree and create a Tab.

Yes Stephan.
In the onValue propo of the button/switch you can use something like this:

// value uses the button's/widget's own value by default or you can specify a number
set("panel_id", value)

I hope I got your question right.
Cheers

You can't create tabs in a panel that already contains non-tab widgets.

Thank you! I've got it now :laughing:

Thank you!!

Hi ClelsonLopes,

thx for your replay but with this i can only set 1 tab value for a button.
I would like to go thrue my tabs like" arrow up is tab 1 and 2 and arrow down is back tab 1 and 0"

Is this possible?
Thanks a lot for your help

Hi Stephan, now I got what you want to do. Yes, it's possible.

For the button to switch tabs up, you can use this in the onValue prop of the button:

const panelValue = get("panel_1") // gets the value of the panel containing all the tabs and stores it in a variable
if (panelValue < 3) set("panel_1", panelValue + 1) //checks the max value of the panel, which is the number of tabs inside of it and increase its value

For the button to scroll tabs backwards, just use:

const panelValue = get("panel_1")
if (panelValue > 0) set("panel_1", panelValue - 1) 

Thank you very much. That works like a charm :wink:

Do you know how i can set up the default tab of a panel? if i went back to that panel its starts every time from tab 0.

1 Like

Yes, there is a default prop, under value tab in the inspector. Just set it to the tab number you want as default.

Yes i know but it did not reset after i moved to another site and come back to the panel

What do you mean by moving to another site?
Actually, the default value only applies when the session is loaded.
Once it's loaded, you need to set other actions to switch back to a desired tab.

Ah ok. I mean when i switch to another tab in my template, sry :wink:

Which action are the best for such a tab reset ( to default tab ) ?

I think the best way is using set("panel_id", value) in the onValue prop of whichever widget you press to get back to the target tab.

Alright i will give it a try :slight_smile:

thx a lot