Skip to main content

ToolBoxItem

Struct ToolBoxItem 

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

One section of a ToolBox. Construct with ToolBoxItem::new and pass to ToolBox::add, or use the convenience ToolBox::item / ToolBox::item_id builders directly when leading / trailing slots and tooltip are not needed.

Layout of the header row:

[indicator] [leading?] [label] [spacer] [trailing?] [chevron]

Both leading and trailing accept any impl Widget — typical uses are a small IconWidget, a Checkbox (checkable section), a Badge (count), or a Button (per-row action).

Implementations§

Source§

impl ToolBoxItem

Source

pub fn new( label: impl Into<LocalizedString>, content: impl Widget + 'static, ) -> Self

Build an item with an inline content widget. The label may come from tr!(...) (translated) or lit!(...).

Source

pub fn new_id(label: impl Into<LocalizedString>, content_id: WidgetId) -> Self

Build an item whose content is a pre-registered widget id.

Source

pub fn leading(self, widget: impl Widget + 'static) -> Self

Attach a leading-slot widget rendered before the label (after the selection indicator bar). Use for a small IconWidget, a Checkbox for checkable sections, a Badge, or any other label-sized widget. The slot widget owns its own events — a Checkbox inside the leading slot toggles independently of the header’s own tap.

Source

pub fn trailing(self, widget: impl Widget + 'static) -> Self

Attach a trailing-slot widget rendered between the row’s flexible spacer and the chevron. Use for per-row actions — a dismiss button, a badge, a secondary Toggle. The slot widget owns its own events: tapping a Button inside the trailing slot fires the button’s action; gesture recognisers on the trailing widget stop the header’s own tap from firing, so a close-button click does not also select the section.

Source

pub fn tooltip(self, text: impl Into<LocalizedString>) -> Self

Attach a plain-text tooltip shown after a hover delay on the header row. The text may come from tr!(...) (translated, locale-reactive) or lit!(...). Mirrors .tooltip(...) on Button / IconButton / MenuItem. Clears any previously set rich or composite tooltip (the last tooltip setter called wins).

Source

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

Attach a rich tooltip resolved from the app-wide TooltipRegistry by key. Clears any previously set plain or composite tooltip (the last tooltip setter called wins).

Source

pub fn rich_tooltip_content(self, content: TooltipContent) -> Self

Attach a rich tooltip driven by inline TooltipContent — for one-offs that don’t belong in the registry. Clears any previously set plain or composite tooltip (the last tooltip setter called wins).

Source

pub fn composite_tooltip(self, content: impl Widget + 'static) -> Self

Attach a composite tooltip — an arbitrary impl Widget body shown in a larger, scrollable overlay after a longer hover delay. Use for rich on-demand previews: charts, property tables, image thumbnails. Clears any previously set plain or rich tooltip (the last tooltip setter called wins).

Source

pub fn enabled(self, enabled: impl Into<Prop<bool>>) -> Self

Disable the item: its header renders in the disabled text role, click and keyboard activation are ignored, and arrow navigation skips it. Accepts a static bool or a reactive Signal<bool>.

Forwarded to the arena via ctx.enabled_when(header_id, self.enabled.clone()) at build time; the arena is then the single source of truth and ANDs with ancestors — disabling the surrounding ToolBox (or any ancestor) disables every item regardless of this flag.

Trait Implementations§

Source§

impl Debug for ToolBoxItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more