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, adds the popover content as a dormant subtree whose panel is built the first time it is opened, 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.

§Keyboard

Beyond whatever activates the trigger itself, Alt+ArrowDown opens the popover and Alt+ArrowUp closes it — the platform disclosure chord (Win32 / WinForms / WPF drop-downs, and the W3C ARIA combobox pattern). Every consumer inherits it, so PopoverButton, PopoverIconButton and ColorEdit share one implementation. F4 is deliberately not bound here: this generic also backs toolbar chevrons and menu buttons, which carry no such convention, so the drop-down fields bind it themselves.

// 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; on_close_with also says why the popover closed (a [DismissReason]: an outside press, Escape, the popover closing itself, a cascade).

§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, IconButton and OverlayTrigger. Captures the few points where the 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).