+1 vote

Hi,

I'm trying to find a control or a way to have a container open or collapse if you press on the title bar like this: https://en.wikipedia.org/wiki/Accordion_(GUI)

The Godot inspector tab in the editor uses this a lot, but I can not figure out how to do it in my game other then custom build. Is there some control or something I overlooked?

I tried a custom solution with a VBoxContainer containing a button and another container.

VBoxContainer
   Button
   VBoxContainer
        Label
        Label
        Label
    Button2
    VBoxContainer2
        Label
        Label
        Label

I added an AnimationPlayer to animate the rectscale.y of the inner container.

func _on_Button_pressed():
    if(container.rect_scale.y == 1):
        player.play_backwards("Accordion")
    else:
        player.play("Accordion")

It has a nice animation but the ui elements following the shrinked container did not relocate leaving a blank space between the button and the next ui elements. Only if I hide the inside container, the ui updates its positions, but then I can not animate the accordion.

func _on_Button_pressed():
    if(container.visible):
        container.hide()
    else:
        container.show()
in Engine by (20 points)
edited by

Any chance you found a solution for this? I want to do exactly the same in my UI.

This is somehow the first result and the linked answer isn't showing in the top 3 results.
There is a duplicate that got the answer:
https://godotengine.org/qa/42199/how-to-make-folding-menu?show=42221#a42221

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.