Connecting signal of nested button, with multiple instances of the same button in different scenes

Godot Version

v4.3.stable.official [77dcf97d8]

Question

How do I manage a menu with lots of subpages?

Hi,

I’m creating a menu UI inside a scrollcontainer.
All menus are different but they have the same buttons to switch between different pages.
As of now the pages are all contained inside a Node2D container and I cycle through them to hide and show only what I need.
The pages are all different scenes but they all have the same “info” tab to switch between the nodes. Like so:

 ->Container
    ->->Home(ScrollContainer)
       ->->->InfoTab (Buttons to switch between pages)
       ->->->PageContent
    ->->News(ScrollContainer)
       ->->->InfoTab (Buttons to switch between pages)
       ->->->PageContent
    ->->Other(ScrollContainer)
       ->->->InfoTab (Buttons to switch between pages)
       ->->->PageContent

Obviously I can’t put the info tab outside because then it wouldn’t scroll so what would be the best approach? I can’t manually connect all the instances of these buttons, they are nested inside scenes and I can’t wrap my head around to find the best way to do it.
It gets even messier when I have to think how to make subpages inside the news page.

Should I make every page inside a scrollcontainer and disable the content (except the info tab) and switch that instead of switching the entire page?
Is there a better way to organize menus with multiple sub-pages?

Thanks

I am not quite sure I understand.
I believe you are using a TabContainer with 3x TabBars for each PageContent.
Clicking on the TabBar will switch the panel to display the appropriate PageContent. All the functionality is inbuilt and works out of the box.

If you want to code the functionality yourself, then you can add every ScrollContainer to a group.
Clicking on either InfoTab will then:

  • Call every member of the group to hide themselves
  • get_parent().show() for the InfoTab that was clicked.

If you really want to use a signal, then you can send a signal from Infotab to the Root Container while giving the appropriate Scrollcontainer as a parameter. show_tab.emit(%yourScrollContainer) The rootContainer will then connect to the signal and then loop through its children to hide them while showing the ScrollContainer that it got as a parameter

1 Like

Yes the TabBar seems to be the solution I was searching for the infobar i’m building. Thank you.
I managed to achieve what I wanted with a combination of tabbars and hiding/showing visibility of pages.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.