pub struct ToolbarAction { /* private fields */ }Expand description
A toolbar command: a label + an icon (both required), plus optional
tooltip/toggle, an activation handler, an overflow priority, and an
always_overflow flag. Renders as an icon-only IconButton inline (the
label is its tooltip + accessible name) and as a labelled MenuItem in the
overflow menu.
Implementations§
Source§impl ToolbarAction
impl ToolbarAction
Sourcepub fn new(
label: impl Into<LocalizedString>,
icon: impl Fn() -> IconWidget + 'static,
) -> Self
pub fn new( label: impl Into<LocalizedString>, icon: impl Fn() -> IconWidget + 'static, ) -> Self
A new action with the given (translatable) label and icon factory,
and a no-op handler. The label is the inline button’s tooltip +
accessible name (the button is icon-only); the icon factory builds the
glyph for both the inline IconButton and the overflow menu row
(IconWidget isn’t Clone, so it is a factory).
Turn this action into a dropdown: its inline control becomes a
PopoverIconButton that opens the MenuList built by factory
(instead of a plain button that runs on_activate), and in the overflow
it becomes a submenu. MenuList isn’t Clone, so pass a factory that
builds a fresh one. Mutually exclusive with on_activate / toggle
(the menu owns the interaction).
Sourcepub fn tooltip(self, text: impl Into<LocalizedString>) -> Self
pub fn tooltip(self, text: impl Into<LocalizedString>) -> Self
Plain-text tooltip shown after a hover delay (also the AT name
supplement in IconOnly mode). Overrides any previously set rich
tooltip — every setter clears the other so last-call wins.
Sourcepub fn rich_tooltip(self, key: impl Into<String>) -> Self
pub fn rich_tooltip(self, key: impl Into<String>) -> Self
Attach a rich tooltip resolved from the app-wide tooltip registry.
The key is looked up via
TooltipRegistry at build
time; the resolved body text supports inline markup
([label](url), *italic*, **bold**) and the entry’s
shortcut / “more” fields are rendered automatically.
Overrides any previously set plain .tooltip(...) — every setter
clears the other so last-call wins.
Sourcepub fn rich_tooltip_content(self, content: TooltipContent) -> Self
pub fn rich_tooltip_content(self, content: TooltipContent) -> Self
Attach a rich tooltip driven by inline
TooltipContent — for
one-off tooltips that aren’t worth registering in the central
catalog. Overrides any previously set plain .tooltip(...).
Sourcepub fn composite_tooltip(
self,
factory: impl Fn() -> Box<dyn Widget> + 'static,
) -> Self
pub fn composite_tooltip( self, factory: impl Fn() -> Box<dyn Widget> + 'static, ) -> Self
Attach a composite tooltip whose body is built by factory — an
arbitrary widget tree (tabbed sections, charts, conditional rows).
Because ToolbarAction is Clone, the body is supplied as a
factory closure (not a Box<dyn Widget> instance, which is not
Clone); the closure is invoked to produce a fresh body for the
inline button. Overrides any previously set tooltip — every setter
clears the others so last-call wins.
Sourcepub fn enabled(self, enabled: impl Into<Prop<bool>>) -> Self
pub fn enabled(self, enabled: impl Into<Prop<bool>>) -> Self
Enabled state, static or reactive.
Sourcepub fn on_activate(self, f: impl Fn(&mut EventContext<'_>) + 'static) -> Self
pub fn on_activate(self, f: impl Fn(&mut EventContext<'_>) + 'static) -> Self
Activation handler (tap / Enter / Space / AT click / menu activate).
Sourcepub fn toggle(self, state: Signal<bool>) -> Self
pub fn toggle(self, state: Signal<bool>) -> Self
Make this a checkable (toggle) action bound to state. Inline it reads
as a pressed toggle button; in overflow as a checkmark menu item.
Sourcepub fn priority(self, priority: i32) -> Self
pub fn priority(self, priority: i32) -> Self
Overflow priority — actions with the lowest priority collapse into
the menu first (NSToolbar semantics). Default 0.
Sourcepub fn always_overflow(self) -> Self
pub fn always_overflow(self) -> Self
Always live in the overflow menu, never inline (WinUI secondary command).
Trait Implementations§
Source§impl Clone for ToolbarAction
impl Clone for ToolbarAction
Source§fn clone(&self) -> ToolbarAction
fn clone(&self) -> ToolbarAction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolbarAction
impl !Send for ToolbarAction
impl !Sync for ToolbarAction
impl !UnwindSafe for ToolbarAction
impl Freeze for ToolbarAction
impl Unpin for ToolbarAction
impl UnsafeUnpin for ToolbarAction
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