pub enum MenuRole {
Custom,
Separator,
Cut,
Copy,
Paste,
SelectAll,
LookUp,
}Expand description
What an item means, as far as anything outside the app is concerned.
The roles exist for two reasons and neither is decoration. A host with
a native menu maps them onto its own standard items, so Copy is the
platform’s Copy — its wording, its accelerator, its position; and the
core acts on the ones it can act on without asking anybody
(MenuRole::SelectAll) or with one round trip through the host (the
clipboard three). MenuRole::Custom is an item the app invented,
which only the app can perform.
Variants§
Custom
The app’s own item: choosing it posts the item’s payload and the core does nothing else.
Separator
A divider. Never focusable, never chosen, no payload.
Cut
Copy
Paste
SelectAll
LookUp
Show the platform’s definition/Look Up panel for the selection. The core cannot draw one: with no host to answer it, the item is not offered.
Implementations§
Source§impl MenuRole
impl MenuRole
Sourcepub const ALL: [MenuRole; 7]
pub const ALL: [MenuRole; 7]
Every role, in wire order: the index a binding that spells roles as
numbers sends (C’s KUI_MENU_*), pinned there by name. Append-only,
like every list a C enum restates.
Sourcepub fn from_name(name: &str) -> Option<MenuRole>
pub fn from_name(name: &str) -> Option<MenuRole>
The role a wire name spells, for the bindings that take roles as
strings: the inverse of Self::name, so a binding cannot accept
a spelling the event will not report back. None for a name that
is no role.
Sourcepub fn default_label(self) -> &'static str
pub fn default_label(self) -> &'static str
The label the stock renderer draws when the item declares none. A native renderer ignores this and uses the platform’s wording, which is the point of having a role at all.
Sourcepub fn default_accel(self) -> &'static str
pub fn default_accel(self) -> &'static str
The shortcut the stock renderer draws beside the row when the item
declares none, spelled the way the platform spells it — Command on
macOS, Control elsewhere, the same split KeyMods::primary makes
for the key that produces it.
Display only, like every accelerator here: the core binds nothing,
and the row only names the key the host is already handling. Empty
for the roles with no standard shortcut — Custom above all, since
an app’s own accelerator is the app’s to declare
(MenuItem::accel) — and empty for LookUp, whose shortcut
belongs to the one platform that has the panel and draws its own
menu anyway.
Sourcepub fn is_builtin(self) -> bool
pub fn is_builtin(self) -> bool
Whether the core performs this itself, or with one hand from the
host. false is an item only the app can carry out.
Trait Implementations§
impl Copy for MenuRole
impl Eq for MenuRole
impl StructuralPartialEq for MenuRole
Auto Trait Implementations§
impl Freeze for MenuRole
impl RefUnwindSafe for MenuRole
impl Send for MenuRole
impl Sync for MenuRole
impl Unpin for MenuRole
impl UnsafeUnpin for MenuRole
impl UnwindSafe for MenuRole
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.