[resolved] Problem with MenuButton : repetition of its popup items

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

Hye everyone,

I am making an Addon and I have created a MenuButton. Every time I restart Godot, the items in the PopupMenu of the MenuButton multiply. The code is simple.

func _ready() -> void:
init_FileMenu()

func init_FileMenu() :
var menu = fileMenu.get_popup()

menu.add_item("New Tree")
menu.add_item("Open...")
menu.add_separator()
menu.add_item("Save")
menu.add_item("Save as")
menu.add_separator()
menu.add_item("Close")
menu.add_item("Close all")

menu.connect("id_pressed", self, "_on_file_menu_pressed")

Good Day,

:bust_in_silhouette: Reply From: patatra

I still don’t understand where the problem comes from but I found the solution by doing a menu.Clear() at the beginning of the code.