Skip to content

Instantly share code, notes, and snippets.

View lfod1997's full-sized avatar
๐ŸŽˆ
My balloon flew away!!

Oasin Lyu lfod1997

๐ŸŽˆ
My balloon flew away!!
  • Isle O'Wo~lves
View GitHub Profile
@lfod1997
lfod1997 / build_menu.gd
Last active December 8, 2025 09:25
Godot: Create & Use `PopupMenu`s
## Builds menu from given [param items].
## [br][url=https://gist.github.com/lfod1997/6e4ad613637d7e8411c1a603999b41d8]Source and usage[/url].
static func build_menu(
menu_id: StringName, items: Array, handler: Callable,
out_menus: Dictionary[StringName, PopupMenu], out_item_locator: Dictionary[StringName, Dictionary],
separator_id: int = 10000
) -> PopupMenu:
var menu := PopupMenu.new()
var locator: Dictionary[int, int] # Converts ID to index in the built `PopupMenu`
for it in items: