pub struct MenuCommand { /* private fields */ }Expand description
One command in a context menu: its group, words and Lucide glyph, and what it does. A command that exists but cannot run now stays in the menu, disabled, with one line saying why.
Implementations§
Source§impl MenuCommand
impl MenuCommand
Sourcepub fn new(
group: MenuGroup,
label: impl Into<SharedString>,
icon: IconName,
run: impl Fn(&mut Window, &mut App) + 'static,
) -> Self
pub fn new( group: MenuGroup, label: impl Into<SharedString>, icon: IconName, run: impl Fn(&mut Window, &mut App) + 'static, ) -> Self
A command that calls run. Capture a weak handle to act on a board.
Sourcepub fn action(
group: MenuGroup,
label: impl Into<SharedString>,
icon: IconName,
action: impl Action,
) -> Self
pub fn action( group: MenuGroup, label: impl Into<SharedString>, icon: IconName, action: impl Action, ) -> Self
A command that dispatches action, as its key does, and shows that
key.
A submenu of choices, which build fills as it opens.
Sourcepub fn key(self, action: impl Action) -> Self
pub fn key(self, action: impl Action) -> Self
Shows the key bound to action beside the label, for a command
that does what that key does.
Sourcepub fn disabled(self, disabled: bool, reason: impl Into<SharedString>) -> Self
pub fn disabled(self, disabled: bool, reason: impl Into<SharedString>) -> Self
Disables the command when disabled, with reason on a line under
it, such as “The last open Space can’t be closed.”
pub fn group(&self) -> MenuGroup
pub fn label(&self) -> &SharedString
Sourcepub fn reason(&self) -> Option<&SharedString>
pub fn reason(&self) -> Option<&SharedString>
Why the command cannot run now, when it is disabled.
Trait Implementations§
Source§impl Extend<MenuCommand> for GroupedMenu
impl Extend<MenuCommand> for GroupedMenu
Source§fn extend<I: IntoIterator<Item = MenuCommand>>(&mut self, commands: I)
fn extend<I: IntoIterator<Item = MenuCommand>>(&mut self, commands: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for MenuCommand
impl !Send for MenuCommand
impl !Sync for MenuCommand
impl !UnwindSafe for MenuCommand
impl Forget for MenuCommand
impl Freeze for MenuCommandwhere
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
&'static [u8]: Freeze,
*const dyn Action is !null: Freeze,
PhantomData<dyn Action>: Freeze,
*const RcInner<dyn Fn(&mut Window, &mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut Window, &mut App)>>: Freeze,
*const RcInner<dyn Fn(PopupMenu, &mut Window, &mut Context<'_, PopupMenu>) -> PopupMenu> is !null: Freeze,
PhantomData<RcInner<dyn Fn(PopupMenu, &mut Window, &mut Context<'_, PopupMenu>) -> PopupMenu>>: Freeze,
impl Move for MenuCommand
impl Unpin for MenuCommand
impl UnsafeUnpin for MenuCommandwhere
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
&'static [u8]: UnsafeUnpin,
*const dyn Action is !null: UnsafeUnpin,
PhantomData<dyn Action>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut Window, &mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut Window, &mut App)>>: UnsafeUnpin,
*const RcInner<dyn Fn(PopupMenu, &mut Window, &mut Context<'_, PopupMenu>) -> PopupMenu> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(PopupMenu, &mut Window, &mut Context<'_, PopupMenu>) -> PopupMenu>>: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more