create a menu that expands and collapse

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lalel345

create a menu that expands and collapses child nodes

This sounds a lot like a Tree control. If that’s not what you’re after, then maybe you want to provide a more detailed description?

jgodfrey | 2020-12-13 15:33

What do you mean by Tree control, I want to want to collapse the menu and then expand it vertically when I click on it in the control

lalel345 | 2020-12-15 12:04

:bust_in_silhouette: Reply From: jgodfrey

My response above contains a link to the Tree documentation. Though, for a visual reference, that’s the control that’s used in the Godot editor for the Scene Tree and the FileSystem panel.

It provides the expand / collapse feature that you mention, though depending on your requirements, it may not be what you need…

I copy the example code and it doesn’t work, as it would with a label

lalel345 | 2020-12-16 13:21

look at this forum thread: How to make folding menu? - #5 by viciousvegs

I have a post in it that says to use a control node for volume so nothing overlaps, and the top level container for inputs/input_containers to hide/show the content.

look at the forum thread link to see more info, but it goes something like this:
-control_node
-toggle button
-top_level container
—inputs/other input containers

signal to control_node from toggle button:
if toggled:
control_node = toggle_button.custom_minimum_size.y
top_level_container.hide()
else:
control_node = toggle_button.custom_minimum_size.y + top_level_container.custom_minimum_size.y
top_level_container.show()