+1 vote

I created them in the designer, adding a few buttons. I get an item list... but how do I connect to "pressed" with each button?

This is Godot V3.0

asked Feb 5, 2018 in Engine by imekon (229 points)

I believe the second half of that step by step guide will give you what you need

I know how to connect ordinary buttons but how do I connect buttons in a MenuButton? I can't select them in the editor, they're in a modal dialog.

In case it helps anyone, it's hard to find out how to edit the popup items for a MenuButton. You can't do it in the Inspector; an "Items" button appears in the header of the main viewer when you select the MenuButton in the scene. Click that to edit the items.

1 Answer

+3 votes
Best answer

Ok, so after a bit of digging and testing(like 10-20 minutes) i found out that you need to use the get_popup method and connect the id_pressed signal from that popup that you got, aka like this:


and the function is set like this:

func func_name( ID ):
      # Some Beautiful Code Here <3

and ID is the number of the item that was selected...

hope i helped this time was fun exploring it tho

answered Feb 5, 2018 by rustyStriker (1,079 points)
selected Feb 5, 2018 by imekon


extends PanelContainer

onready var menuButton = $Panel/MenuButton

func _ready():
    var popup = menuButton.get_popup()
    popup.connect("id_pressed", self, "file_menu")

func file_menu( id ):
    match id:

And a match statement!

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.