Skip to main content

Module tab

Module tab 

Source
Expand description

Tab order and focus scopes for the keyboard: Tab moves through a scope’s stops in reading order, or as explicit indices and groups say (egui_pop_model::tab); F6 moves between panels.

A scope is a region whose Tab order egui-pop decides: a panel (ScopeKind::Panel) or a modal (ScopeKind::Modal). Inside it, a widget joins the order as a stop (stop); egui-pop’s inputs and sliders do so themselves, any other widget with tab::stop(ui, &response, TabStop::new()).

  • Tab and Shift+Tab from a stop go to the next or previous stop of its scope: reading order by default (rows from top to bottom, left to right), stops with an explicit TabStop::index first, the stops of a TabStop::group together.
  • Disabled fields are skipped (they cannot take the focus); read-only ones are not.
  • In a modal, Tab cycles: after the last stop comes the first, and Shift+Tab goes round the other way. Every control of a modal scope should then be a stop, or Tab never reaches it. (egui-pop’s modal overlays keep the focus inside them anyway: egui only lets the widgets of the top modal layer take it.)
  • In a panel, Tab past the last stop leaves the order to egui, which goes on in the order widgets were drawn (to the next panel).
  • F6 and Shift+F6 move to the next or previous panel scope that has stops, to the stop focused there last (or its first). F6 does nothing while a modal scope or a modal overlay is open. In a window with regions (an application’s), F6 is theirs, and the panel scopes of a region take that region’s turn.
  • A roving group (a toolbar, a strip) is one stop: Tab leaves it and comes back to the widget focused there last, the arrows go inside.
  • The focus on a widget that is not a stop is left to egui (its own Tab order is the order widgets were drawn), and a focused widget that takes the keys itself (a terminal) keeps Tab and F6.
use egui_pop_core::tab::{self, ScopeKind, TabStop};

fn form(ui: &mut egui::Ui, name: &mut String, city: &mut String) {
    tab::scope(ui, "form", ScopeKind::Panel, |ui| {
        let r = ui.text_edit_singleline(city);
        tab::stop(ui, &r, TabStop::new().index(2));
        let r = ui.text_edit_singleline(name);
        tab::stop(ui, &r, TabStop::new().index(1));
    });
}

Structs§

ScopeRecord
One scope as drawn, with its stops.
StopRecord
One stop as drawn.
TabStop
How a widget joins the Tab order.

Enums§

Axis
Which way a roving group runs, which decides its arrows.
ScopeKind
What a scope is, which decides the ends of its Tab order and F6.

Functions§

install
Installs the Tab plugin on a context (once; scope does it).
order
A scope’s stops in Tab order, as drawn in the last pass.
parts
Draws add as the parts of the widget owner (a graph node’s chevron, ports and sliders), inside a roving group: Tab coming into the group lands on the widget, not on its parts.
roving
Draws add as a roving group named name: one Tab stop for all its widgets, the arrows going between them (a toolbar, a strip of icons, a status bar), as ARIA’s toolbar pattern has it.
rovings
The roving groups drawn in the last pass, by name, with their widgets that can take the focus in the order drawn.
scope
Draws add as a Tab scope named name (see the rules).
scopes
The scopes drawn in the last pass, with their stops.
stop
Puts a widget in the Tab order of the innermost scope being drawn (outside any scope, it stays in egui’s order). A widget that cannot take the focus (disabled) is skipped whatever stop says.