Skip to main content

MenuEntry

Struct MenuEntry 

Source
pub struct MenuEntry { /* private fields */ }
Expand description

A menu entry under construction. Build a command with menu_item, a nested submenu with sub_menu, a standard system command with menu_role, and a divider with menu_separator. Attach to a Piece via [Decorate::context_menu] or install app-wide via app_menu.

Implementations§

Source§

impl MenuEntry

Source

pub fn action(self, f: impl Fn() + 'static) -> MenuEntry

Run f when the item is chosen.

Source

pub fn shortcut(self, s: Shortcut) -> MenuEntry

Full shortcut spec, e.g. Shortcut::new("s").shift().

Source

pub fn key(self, key: impl Into<String>) -> MenuEntry

Convenience: the platform’s primary modifier (⌘ / Ctrl) + key.

Source

pub fn enabled(self, on: bool) -> MenuEntry

Source

pub fn role(self, role: MenuRole) -> MenuEntry

Tag a custom command with a standard day_spec::MenuRole (usually you use menu_role).

Source§

impl MenuEntry

Claim one of the platform’s standard menu-bar slots for this submenu: the backend places it where that menu belongs and does NOT add its own stock version. Without a role, a submenu is an app menu and sits between the standard ones.

sub_menu(tr("menu-file"), vec![…]).bar_role(MenuBarRole::File)
Source

pub fn bar_role(self, role: MenuBarRole) -> MenuEntry

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

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

Day API ↩ Guides· daybrite.dev