pub struct MenuEntry { /* private fields */ }Expand description
One leaf command in the menu tree. Both the builder and the stored spec.
Implementations§
Source§impl MenuEntry
impl MenuEntry
Sourcepub fn new(title: impl Into<LocalizedString>) -> Self
pub fn new(title: impl Into<LocalizedString>) -> Self
Start a new leaf item with the given (possibly mnemonic-bearing,
localized) title. Allocates a process-unique [MenuItemId].
Sourcepub fn intent(self, name: &'static str) -> Self
pub fn intent(self, name: &'static str) -> Self
Fire this intent by name when the item is chosen (in-window or native).
Sourcepub fn on_activate(self, f: impl Fn(&mut EventContext<'_>) + 'static) -> Self
pub fn on_activate(self, f: impl Fn(&mut EventContext<'_>) + 'static) -> Self
Run this closure when the item is chosen. Runs after intent, if both
are set. The escape hatch for behaviour that isn’t a plain intent.
Sourcepub fn shortcut(self, id: &'static str) -> Self
pub fn shortcut(self, id: &'static str) -> Self
Bind the displayed shortcut to a ShortcutRegistry entry by id. The
in-window item shows the resolved chord; the native item gets a key
equivalent (and the OS fires it directly).
Sourcepub fn enabled(self, enabled: impl Into<Prop<bool>>) -> Self
pub fn enabled(self, enabled: impl Into<Prop<bool>>) -> Self
Enabled state (static or signal-bound).
Sourcepub fn visible(self, visible: impl Into<Prop<bool>>) -> Self
pub fn visible(self, visible: impl Into<Prop<bool>>) -> Self
Visibility (static or signal-bound). A hidden item collapses to zero
height in the in-window menu (reactively); on the native menu it is
omitted from the snapshot at build time (toggling it settles on the next
menu rebuild — for fully-dynamic native menus prefer
MenuModel::remove / MenuModel::push_item).
Sourcepub fn checkable(self, state: Signal<bool>) -> Self
pub fn checkable(self, state: Signal<bool>) -> Self
Make this a two-state checkbox item bound to state. Activation flips
state — use when the signal is the source of truth.
Sourcepub fn checked(self, state: Signal<bool>) -> Self
pub fn checked(self, state: Signal<bool>) -> Self
Show a checkmark that reflects state read-only. Activation does not
write it — pair with intent / on_activate
that drive the change; the checkmark then follows state reactively. Use
when the truth is owned elsewhere (e.g. DockingModel::dock_open_signal),
where two-way checkable would fight the model.
Sourcepub fn tri_checkable(self, state: Signal<CheckState>) -> Self
pub fn tri_checkable(self, state: Signal<CheckState>) -> Self
Make this a tri-state checkbox item bound to state.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for MenuEntry
impl !Send for MenuEntry
impl !Sync for MenuEntry
impl !UnwindSafe for MenuEntry
impl Freeze for MenuEntry
impl Unpin for MenuEntry
impl UnsafeUnpin for MenuEntry
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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