MenuButton + PopupMenu

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

Hello gyus!
I have a little question about combination with double menu:
I use the: MenuButton like a prent script, and PopupMenu like a child.
How it looks now:
// Script
enter image description here
// View
enter image description here
View how it must to be:


With ability to when I’m select the item from second popup menu, it must be setted to that place if its possible.
enter image description here
Thank you very much gyus! I LOVE YOU ALL - KAPU! xD

My problem is: WHen Im create a popup list, he is not show their elements on my MenuButton popup list. (No arrow, no child elements)

FinFan | 2019-11-06 22:55

So let me get this straight: if a user clicks on an item from the “country_list”, that item appears in the “village_list”?

Ertain | 2019-11-07 00:32

Try to draw the scheme:

FinFan | 2019-11-07 01:27

Could you please show me how you have laid out the Control nodes (for example, the MenuButton, PopupMenu, and ItemList nodes)? I need to know how one list flows into another list.

Ertain | 2019-11-07 06:51

It looks like you need GDscript and a signal for when an item of the MenuButton is selected. It could go something like this:

func _ready():
     # Access the "country_menu" PopupMenu through this.
     var country_list_popup_menu: PopupMenu = $country_list.get_popup()
     # Signal for when the user selects an PopupMenu item.
     country_list_popup_menu.connect("id_pressed", self, "_on_country_selected")

 # Function that handles the item selected.
 func _on_country_selected( id ):
       # Code for populating the Dropdown menu or the ItemList. Use the "id" parameter to get which item was selected in the MenuButton.

Ertain | 2019-11-07 07:39

I donw know what happening, but link ButtonMenu + child PopupMenu - doesnt work correctly if you create them from GUI.
I solve my problem by fully using code for it. Parent MenuButton was created by GUI and child PopupMenu - by code.
$ The problem in log: “node not found”, he just can’t see a child node if i set them by any ways except New.

  1. var node = get_node(“sublist”) #error not see
  2. onready var node = $sublist #error not see
    But if you create it by GDScript - no errors all is fine.

SO if any people meet with that problem, the solve looks like:
enter image description here

If you want to do something like that.

Thanks anyway for hearing my call!

FinFan | 2019-11-07 15:18