Skip to main content

Menu

Struct Menu 

Source
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

Source

pub fn new(title: impl IntoValue<String>) -> Menu

Source

pub fn title(self, title: impl IntoValue<String>) -> Menu

Source

pub fn visible(self, visible: impl IntoValue<bool>) -> Menu

In the bar (or its menu) while true.

Source

pub fn item(self, item: MenuItem) -> Menu

Source

pub fn separator(self) -> Menu

Source

pub fn submenu(self, menu: Menu) -> Menu

Source

pub fn children(self, children: impl MenuEntries) -> Menu

Items, separators and submenus, in order.

Source

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§

Source§

impl MenuEntries for Menu

Source§

fn add_to(self, menu: Menu) -> Menu

Source§

impl Menus for Menu

Source§

fn add_to(self, bar: MenuBar) -> MenuBar

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
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn Fn() -> String> is !null: Freeze, PhantomData<RcInner<dyn Fn() -> String>>: Freeze, *const RcInner<dyn Fn() -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn() -> bool>>: Freeze, PhantomData<Entry>: Freeze,

§

impl Move for Menu

§

impl Unpin for Menu
where *const u8 is !null: Unpin, Rc<dyn Fn() -> String>: Unpin, Rc<dyn Fn() -> bool>: Unpin, Rc<dyn Fn()>: Unpin, Rc<dyn Fn() -> Vec<Entry>>: Unpin,

§

impl UnsafeUnpin for Menu
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn Fn() -> String> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn() -> String>>: UnsafeUnpin, *const RcInner<dyn Fn() -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn() -> bool>>: UnsafeUnpin, PhantomData<Entry>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.