[][src]Struct druid::MenuItem

pub struct MenuItem<T> { /* fields omitted */ }

A normal menu item.

A MenuItem always has a title (a LocalizedString) as well a Command, that is sent to the application when the item is selected.

In addition, other properties can be set during construction, such as whether the item is selected (checked), or enabled, or if it has a hotkey.

Implementations

impl<T> MenuItem<T>[src]

pub fn new(title: LocalizedString<T>, command: impl Into<Command>) -> Self[src]

Create a new MenuItem.

pub fn hotkey(self, mods: impl Into<Option<RawMods>>, key: impl IntoKey) -> Self[src]

A builder method that adds a hotkey for this item.

Example


let item = MenuItem::new(LocalizedString::new("My Menu Item"), Selector::new("My Selector"))
    .hotkey(SysMods::Cmd, "m");

pub fn disabled(self) -> Self[src]

Disable this menu item.

pub fn disabled_if(self, p: impl FnMut() -> bool) -> Self[src]

Disable this menu item if the provided predicate is true.

pub fn selected(self) -> Self[src]

Mark this menu item as selected. This will usually be indicated by a checkmark.

pub fn selected_if(self, p: impl FnMut() -> bool) -> Self[src]

Mark this item as selected, if the provided predicate is true.

Trait Implementations

impl<T: Clone> Clone for MenuItem<T>[src]

impl<T: Debug> Debug for MenuItem<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for MenuItem<T>[src]

impl<T> !Send for MenuItem<T>[src]

impl<T> !Sync for MenuItem<T>[src]

impl<T> Unpin for MenuItem<T>[src]

impl<T> !UnwindSafe for MenuItem<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.