Skip to main content

dispatch_tab_keys

Function dispatch_tab_keys 

Source
pub fn dispatch_tab_keys(
    commands: Commands<'_, '_>,
    keys: MessageReader<'_, '_, KeyPressed>,
    tracker: ResMut<'_, FocusTracker>,
    store: ResMut<'_, PropertyStore>,
    buttons: Query<'_, '_, (Entity, &TabStripButton)>,
    disableds: Query<'_, '_, (), With<Disabled>>,
    orders: Query<'_, '_, &DocumentOrder>,
    parents: Query<'_, '_, &ChildOf>,
)
Expand description

Keyboard navigation for tab strips, scoped to children of a tab list (i.e. siblings of the focused TabStripButton). Matches the QTabBar keyboard contract:

  • ArrowRight / ArrowLeft: move focus to the next / previous enabled sibling tab button - and select it immediately (Qt select-on-arrow; QTabBar::keyPressEvent calls setCurrentIndex as focus moves). No wrap-around: at either end the arrow is a no-op, exactly like Qt.
  • Home / End: jump to (and select) the first / last enabled sibling.
  • Enter / Space: activate the focused tab - the same effect as clicking it, i.e. writes Signals[signal_name] = value.
  • Disabled tabs are skipped by every movement, mirroring QTabBar’s enabled-only traversal.

Siblings are identified as all TabStripButton entities that share the focused tab’s parent (the synthesised tab-strip row) and bind to the same signal_name. This keeps the nav strictly inside one tab strip even when several strips coexist in the same app, and never bleeds into non-tab focusables like inputs or buttons sitting alongside the strip.