Skip to main content

MenuCommand

Struct MenuCommand 

Source
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

Source

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.

Source

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.

Source

pub fn submenu( group: MenuGroup, label: impl Into<SharedString>, icon: IconName, build: impl Fn(PopupMenu, &mut Window, &mut Context<'_, PopupMenu>) -> PopupMenu + 'static, ) -> Self

A submenu of choices, which build fills as it opens.

Source

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.

Source

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.”

Source

pub fn group(&self) -> MenuGroup

Source

pub fn label(&self) -> &SharedString

Source

pub fn reason(&self) -> Option<&SharedString>

Why the command cannot run now, when it is disabled.

Trait Implementations§

Source§

impl Extend<MenuCommand> for GroupedMenu

Source§

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)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

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 MenuCommand
where &'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
where &'static str: Unpin, Arc<str>: Unpin, &'static [u8]: Unpin, Box<dyn Action>: Unpin, Rc<dyn Fn(&mut Window, &mut App)>: Unpin, Rc<dyn Fn(PopupMenu, &mut Window, &mut Context<'_, PopupMenu>) -> PopupMenu>: Unpin,

§

impl UnsafeUnpin for MenuCommand
where &'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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ParallelSend for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more