0 votes

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?

in Engine by (393 points)

1 Answer

0 votes
Best answer

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
by (10,229 points)
selected by
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 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 webmaster@godotengine.org with your username.