How the MenuBar widget and its tree structure work
mainThe MenuBar widget manages a tree of menus and items. It acts as the 'root menu' and owns the global state. The hierarchy consists of:
MenuBar: The entry point widget added to your UI.Menu: A container for items, used to build the tree.Item: A single entry in a menu. An item can contain a widget and optionally a childMenu.
Note that Item and Menu are helper structures used to build the tree and cannot function independently of a MenuBar.
MenuBar {
roots: Vec<Item>,
}
Item {
widget,
menu: Option<Menu>,
}
Menu {
items: Vec<Item>,
}