pub struct MenuItem { /* private fields */ }Expand description
A menu item: a title, what choosing it does, and optionally a shortcut, a check mark and a role. Its title, enabled state, check mark and visibility take a literal, a signal or a closure.
ⓘ
MenuItem::new("Save").shortcut(Shortcut::primary('s')).on_select(save)
MenuItem::new("Show Sidebar").bind(sidebar)
MenuItem::new("Large").radio((zoom, Zoom::Large))In view!, its text is its title:
<MenuItem shortcut=Shortcut::primary('s') @select=save>"Save"</MenuItem>.
Implementations§
Source§impl MenuItem
impl MenuItem
pub fn new(title: impl IntoValue<String>) -> MenuItem
Sourcepub fn on_select(self, handler: impl Fn() + 'static) -> MenuItem
pub fn on_select(self, handler: impl Fn() + 'static) -> MenuItem
Called when the item is chosen: clicked, or through its shortcut.
Sourcepub fn shortcut(self, shortcut: impl Into<Option<Shortcut>>) -> MenuItem
pub fn shortcut(self, shortcut: impl Into<Option<Shortcut>>) -> MenuItem
The item’s shortcut, or None for none: some items have one only
on some platforms.
pub fn enabled(self, enabled: impl IntoValue<bool>) -> MenuItem
Sourcepub fn checked(self, checked: impl IntoValue<bool>) -> MenuItem
pub fn checked(self, checked: impl IntoValue<bool>) -> MenuItem
Shows a check mark while true. Choosing the item only calls its
handler: bind toggles a signal instead.
Sourcepub fn bind(self, signal: Signal<bool>) -> MenuItem
pub fn bind(self, signal: Signal<bool>) -> MenuItem
A check mark showing the signal; choosing the item toggles it.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for MenuItem
impl !Send for MenuItem
impl !Sync for MenuItem
impl !UnwindSafe for MenuItem
impl Forget for MenuItem
impl Freeze for MenuItemwhere
*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,
*const RcInner<dyn Fn()> is !null: Freeze,
PhantomData<RcInner<dyn Fn()>>: Freeze,
impl Move for MenuItem
impl Unpin for MenuItem
impl UnsafeUnpin for MenuItemwhere
*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,
*const RcInner<dyn Fn()> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn()>>: UnsafeUnpin,
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