Module cosmic::widget::menu

source ·
Expand description

A MenuBar widget for displaying [MenuTree]s

This API requires the following crate features to be activated: menu

§Example

use iced::widget::button;
use iced_aw::menu::{MenuTree, MenuBar};

let sub_2 = MenuTree::with_children(
    button("Sub Menu 2"),
    vec![
        MenuTree::new(button("item_1")),
        MenuTree::new(button("item_2")),
        MenuTree::new(button("item_3")),
    ]
);

let sub_1 = MenuTree::with_children(
    button("Sub Menu 1"),
    vec![
        MenuTree::new(button("item_1")),
        sub_2,
        MenuTree::new(button("item_2")),
        MenuTree::new(button("item_3")),
    ]
);


let root_1 = MenuTree::with_children(
    button("Menu 1"),
    vec![
        MenuTree::new(button("item_1")),
        MenuTree::new(button("item_2")),
        sub_1,
        MenuTree::new(button("item_3")),
    ]
);

let root_2 = MenuTree::with_children(
    button("Menu 2"),
    vec![
        MenuTree::new(button("item_1")),
        MenuTree::new(button("item_2")),
        MenuTree::new(button("item_3")),
    ]
);

let menu_bar = MenuBar::new(vec![root_1, root_2]);

Re-exports§

Modules§

Structs§

  • The condition of when to close a menu
  • A MenuBar collects MenuTrees and handles all the layout, event processing, and drawing.
  • Nested menu is essentially a tree of items, a menu is a collection of items a menu itself can also be an item of another menu.

Enums§

  • Represents a menu item that performs an action when selected or a separator between menu items.
  • The height of an item
  • The width of an item
  • Methods for drawing path highlight

Functions§

  • A MenuBar collects MenuTrees and handles all the layout, event processing, and drawing.
  • Create a list of menu items from a vector of MenuItem.
  • Create a root menu item.