Skip to main content

Module popup_nav

Module popup_nav 

Source
Expand description

Keyboard interaction for popup widgets: <dropdown> (combobox) and <menu> panels. Matches the Qt contract:

Dropdown, closed + focused header (closed_dropdown_keys):

  • ArrowUp / ArrowDown step the committed value directly through the enabled options (no wrap - QComboBox clamps at the ends).
  • Alt+ArrowDown opens the popup. Space / Enter open it through the existing focused-activation -> click -> header-toggle path.
  • Type-ahead: printable characters jump (and commit) the selection to the next option whose label starts with the typed prefix, wrapping, with a reset timer (PopupNavConfig).

Open popup (popup_nav_lifecycle + popup_nav_keys + follow_hover_highlight):

  • Opening moves keyboard focus into the panel: onto the option row matching the committed value (dropdown - Qt highlights the current item) or onto the panel itself (menu - no initial highlight, like a fresh QMenu). The row highlight is the Focused marker, so .dropdown-option:hover-style CSS (routed through crate::hover::Interaction::hover_tint, which treats Focused like Hovered) and :focus rules both style it - highlight styling stays CSS-reachable with zero new style plumbing.
  • ArrowUp / ArrowDown move the highlight without committing (dropdown clamps like QListView; menus wrap like QMenu), skipping disabled rows and separators. Home / End jump.
  • Enter / Space activate the highlighted row through the existing focused-activation path (activate_focused_on_enter synthesizes the click; the option / menu-item dispatcher commits and closes) - so commit semantics live in exactly one place.
  • Escape closes without committing (the highlight never wrote the value, so the pre-open selection is intact - Qt’s revert contract). lumenc’s close_dialogs_on_escape flips the open signal; the lifecycle system here restores focus to the trigger.
  • Alt+ArrowUp also closes a dropdown popup (Qt).
  • Hovering a row moves the highlight to it; a keyboard move strips the hover highlight - keyboard and hover highlight are one state, last input wins (Qt).
  • Highlight movement scrolls the panel’s internal scroller (skins cap .dropdown-panel height via --lumen-dropdown-max-height + overflow-y: scroll) so the highlighted row stays visible.

Structs§

ActivePopupNav
Resource slot for the live PopupNavSession.
PopupNavConfig
Interaction timings for popup keyboard navigation. This Default is the single Rust-side fallback (blank-no-css contract); embedders can override the resource before the first tick.
PopupNavSession
The one live popup keyboard session (dropdown or menu panel). At most one popup owns the keyboard at a time - nested menus are a later wave; today’s <menu> is a flat panel.
TypeAheadBuffer
Accumulated type-ahead prefix, shared by the open-popup and closed-header paths (only one can be focused at a time).

Functions§

closed_dropdown_keys
Closed-combobox keyboard interaction on the focused dropdown header. Uses the option metadata mirrored onto DropdownButton (the panel body may never have mounted). See the module docs for the exact Qt contract.
follow_hover_highlight
Pointer half of “keyboard highlight and hover highlight are the same state”: hovering a row of the open panel moves the focus highlight onto it (no FocusVisible - pointer-driven), so the next Enter activates what the pointer indicated and arrow keys continue from it. Runs after hit_test so this tick’s hover is visible.
popup_nav_keys
Keyboard handling while a popup session is live: highlight movement, type-ahead, and Alt+ArrowUp close. Commit keys (Enter / Space) are deliberately not handled here - they flow through lumen_input::activate_focused_on_enter -> ClickEvent -> the option / menu-item click dispatchers, so keyboard and pointer commits share one code path.
popup_nav_lifecycle
Open/close bookkeeping for popup keyboard sessions.