pub struct Menu { /* private fields */ }Expand description
A menu of the bar, or a submenu of another menu.
ⓘ
Menu::new("File")
.item(MenuItem::new("New").shortcut(Shortcut::primary('n')).on_select(new))
.submenu(Menu::new("Open Recent").children_with(move || {
recent.get().into_iter().map(|path| MenuItem::new(path.clone()).on_select(move || open(&path))).collect::<Vec<_>>()
}))
.separator()
.item(MenuItem::new("Settings…").role(MenuRole::Settings).on_select(settings))In view!, <Menu title="File">…</Menu> takes items, <MenuSeparator/>s
and Menus as children.
Implementations§
Source§impl Menu
impl Menu
pub fn new(title: impl IntoValue<String>) -> Menu
pub fn title(self, title: impl IntoValue<String>) -> Menu
Sourcepub fn visible(self, visible: impl IntoValue<bool>) -> Menu
pub fn visible(self, visible: impl IntoValue<bool>) -> Menu
In the bar (or its menu) while true.
pub fn item(self, item: MenuItem) -> Menu
pub fn separator(self) -> Menu
Sourcepub fn children(self, children: impl MenuEntries) -> Menu
pub fn children(self, children: impl MenuEntries) -> Menu
Items, separators and submenus, in order.
Sourcepub fn children_with<E: MenuEntries>(
self,
children: impl Fn() -> E + 'static,
) -> Menu
pub fn children_with<E: MenuEntries>( self, children: impl Fn() -> E + 'static, ) -> Menu
Entries built by children, and built again whenever what it reads
changes: a list of recent files, say.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Menu
impl !Send for Menu
impl !Sync for Menu
impl !UnwindSafe for Menu
impl Forget for Menu
impl Freeze for Menu
impl Move for Menu
impl Unpin for Menu
impl UnsafeUnpin for Menu
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more