Skip to main content

Module popover_widget

Module popover_widget 

Source
Expand description

PopoverWidget<T> — a generic trigger that opens a popover when activated, plus the PopoverButton / PopoverIconButton aliases.

Wraps a caller-built trigger (T: PopoverTrigger) with overlay wiring: owns a popover_open: Signal<bool> toggled on activate / dismiss, sets has_popup and expanded_when on the inner trigger so AT announces the disclosure state, pre-builds the popover content as a dormant subtree, and shows / hides it via [OverlayRequest]. The set_dormant + activate + show_overlay sequence and the dismiss-callback shape match DateEdit so behavior across the disclosure family stays consistent.

// Text trigger (HasPopup::Dialog by default, no caret):
let _w = PopoverButton::new(Button::new(lit!("Choose…")).variant(ButtonVariant::Plain))
    .content(TextWidget::new(lit!("Pick")));

// Icon trigger (HasPopup::Menu by default, corner caret on):
let _w = PopoverIconButton::new(IconButton::add().toolbar())
    .content(MenuList::new().item(MenuItem::new(lit!("New file"))));

§Trigger configuration overrides

build() configures the inner trigger by calling has_popup, expanded_when, and on_activate_fn (and share_interaction when a caret is shown). These replace any previous values the caller set — in particular any on_activate_fn set before ::new is discarded, because the activate slot is owned by the popover wiring. Use on_open / on_close, or observe open_signal, for side effects.

§Per-trigger differences (the PopoverTrigger trait)

Button and IconButton differ only in: the default has_popup kind, whether the disclosure caret shows by default, whether the caret is suppressed (IconButton at Compact), and how the caret’s color is derived. Those four points live behind PopoverTrigger; everything else is shared by the generic.

Structs§

PopoverWidget
A trigger paired with a popover surface. See the module docs for the contract on which trigger properties get overridden during build(). Use the PopoverButton / PopoverIconButton aliases for the concrete trigger types.

Traits§

PopoverTrigger
A trigger widget usable with PopoverWidget. Implemented for Button and IconButton. Captures the few points where the two triggers differ; everything else is handled by the generic wrapper.

Type Aliases§

PopoverButton
A Button that opens a popover when activated. Alias for PopoverWidget<Button>HasPopup::Dialog, no caret by default.
PopoverCustom
A popover whose trigger is an arbitrary widget, wrapped in OverlayTrigger.
PopoverIconButton
An IconButton that opens a popover when activated. Alias for PopoverWidget<IconButton>HasPopup::Menu, corner caret on by default (skipped at Compact).