Topic was automatically imported from the old Question2Answer platform.
Asked By
Macryc
Hi All. I have a popup menu with a bunch of items. I want them to pop up as enabled or disabled depending on some conditions in the game (eg, can’t build a table if you don’t have wood in your inventory). How do I access the popup menu’s items’ properties in gdscript?
Use set_item_disabled(<item_id>, <bool>). Here’s an example:
extends PopupMenu
func _ready():
# add three items to the PopupMenu
add_item("Test1") # id: 0
add_item("Test2") # id: 1
add_item("Test3") # id: 2
# disable only the second item,
# the rest will be enabled by default
set_item_disabled(1, true)
popup() # show the PopupMenu
Is there a way to completely remove them from the menu instead of just greying them out?