How do you use OptionsButton and MenuButton.

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

The documentation isn’t very clear on how to use these control nodes. Do I need to add items to them programmatically or can I do that in the editor? If I can do it in editor, how do I add items? I tried to add children nodes, or even a PopupMenu node with its own children, but the OptionsButton and MenuButton still don’t display any of these, and are not behaving the way I would expect. Any help would be appreciated.

:bust_in_silhouette: Reply From: Bartosz

here code that I used in demo of character screen:

func generate_selection(items):
	var ui_node = OptionButton.new()
	for item in items:
		ui_node.add_item(item)
	return ui_node

Basically you are adding items that are strings to option button similary you can work with MenuButton but you need to add items to its popup and not button directly e.g. your_menu_button.get_popup().add_item("your item")