Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Inputs, field states and Tab order

egui-pop’s inputs are one component, the decorated input (egui_pop_core::input), around a text, masked, multi-line, number, path or search field; one field state model (egui_pop_model::field) that every input shows the same way, the sliders included; and a Tab order decided per focus scope (egui_pop_core::tab), with F6 between the window’s regions.

The decorated input

use egui_pop::egui;
use egui_pop::core::icon::Icon;
use egui_pop::core::input::{Attached, Input};
use egui_pop::model::field::FieldState;

fn export_row(ui: &mut egui::Ui, folder: &mut String, size: &mut f64, name: &mut String) {
    let out = Input::path(folder, "Folder")
        .leading_icon(Icon::Folder)
        .button(Attached::text("Browse…", "Browse for a folder"))
        .state(FieldState::new().required())
        .show(ui);
    if out.button == Some(0) { /* open the file chooser */ }

    Input::number(size, "Long edge")      // a number or an expression
        .unit("px")
        .choices(["1024", "2048", "4096"]) // a dropdown chevron
        .show(ui);

    let out = Input::text(name, "Export name")
        .placeholder("File name")
        .clearable(true)
        .button(Attached::icon(Icon::Save, "Export").menu(["Export as…", "Export settings…"]))
        .show(ui);
    if let Some((_, item)) = out.menu { let _ = item; /* a split button's item */ }
}
DecoratorHowWhat it does
Placeholder.placeholder(text)Shown while the field is empty, in field.tone.muted.text; assistive technologies read it as the placeholder
Leading, trailing slots.leading_icon, .prefix, .suffix, .unit, .trailing_iconIcons and texts inside the field, before or after the value, never edited
Clear ✕.clearable(true) (on for Input::search)Shown while there is a value and the field can be edited; Tab reaches it, Enter or Space presses it, the focus goes back to the field. One change: one undo step when the field is bound to a store, one step in the field’s own Ctrl+Z history
Resetfrom the stateShown while the state offers “reset to default”; puts back .default_value(text)
Attached buttons.button(Attached::text(..)), Attached::icon(..)Joined to the field’s end, each a button of its own; its click is InputOutput::button
Split buttonAttached::..(..).menu(items)The action and a chevron opening a menu (InputOutput::menu); input::split_button draws one on its own
Dropdown chevron.choices(items)Opens a list of values; choosing one sets the field (InputOutput::choice)

The field is egui’s TextEdit, so it follows the focus rules of every text input: while it has the focus, Escape and Enter are its own (Escape leaves the field, Enter commits it) and no key binding fires on them. A number field (Input::number) reads what is typed as a slider’s typed entry does (+ - * / ^, parentheses, either decimal separator, a unit ignored) and commits it when it loses the focus: Enter, Tab, a click elsewhere. Escape leaves it with nothing: what was typed is dropped and the value stays.

Masked and multi-line fields

Experimental, as the whole input.

use egui_pop::egui;
use egui_pop::core::input::Input;

fn account(ui: &mut egui::Ui, token: &mut String, notes: &mut String, chat: &mut String) {
    Input::masked(token, "API token").show(ui);

    let out = Input::multiline(notes, "Notes")
        .rows(3)      // its height while the text is short (2 by default)
        .max_rows(6)  // it grows with its text up to 6 lines, then scrolls (8 by default)
        .show(ui);
    if out.submitted { /* Ctrl+Enter (Cmd+Enter on macOS) */ }

    let out = Input::multiline(chat, "Message").submit_on_enter(true).show(ui);
    if out.submitted { /* Enter; Shift+Enter starts a new line */ }
}

A masked field (Input::masked: a password, a token, a key) draws each character as a bullet and cannot be copied or cut from. Assistive technologies get its name and the password-input role, never its value: the value and the text runs they read are bullets too, and agents read its kind (masked), not its value. A read-only masked field stays masked.

A multi-line field (Input::multiline) is rows lines tall while its text is short, grows line by line with its text (wrapped lines count) up to max_rows, then scrolls; assistive technologies read it as a multi-line text input. Its keys:

KeyDefaultWith .submit_on_enter(true)
Entera new linesubmits (InputOutput::submitted)
Shift+Entera new linea new line
Ctrl+Enter (Cmd+Enter)submitssubmits
Tab, Shift+Tabthe next or previous stopthe same

Submitting keeps the focus in the field. The key dispatcher leaves only Escape and Enter without Ctrl or Alt to a text field: when the keymap binds Ctrl+Enter, the binding runs instead. The slots, the clear ✕, the markers and attached buttons stay on the field’s first line.

Every part has an accessible name: the field its label, the ✕ “Clear label”, the reset “Reset label to default”, the chevron “label, choices” (a list box popup, expanded or not), a split button’s chevron “label, more” (a menu popup).

Field states

use egui_pop::model::field::{Baseline, FieldState};

let saved = "Sunset".to_string();
let title = "Golden hour".to_string();
let state = FieldState::new()
    .compare(&title, Some(&saved), &"Untitled".to_string()) // modified against saved
    .required()
    .validated(None);                                      // or Some(message)
assert!(state.is_editable());

let off = FieldState::new().disabled("Needs an open image");
assert!(!off.is_focusable());
StateBuilderEdgeMarkerAssistive technologies
Disabled.disabled(reason)mutedan “i”; the reason is the tooltipdisabled, the reason as the description
Invalid.invalid(message), .validated(Option)field.tone.danger.border-color, and an outlinea crossed circle; the message is the tooltipinvalid, the message as the description
Pending.pending()field.tone.info.border-color, and an outlinea clockbusy
Modified.modified(Baseline::Saved / Default), .compare(value, saved, default)field.tone.accent.border-colora dot; a reset arrow when it differs from its default“changed since saved” or “from the default” in the description
Required.required()nonean asterisk (field.tone.warning.border-color)required
Read-only.read_only()none, and the field.tone.muted.fill filla lockread-only

The edge is a strip along the field’s leading side in the colour of its first state, in that order of precedence; every state also has its marker, so none rests on colour alone. A disabled field cannot take the focus and is greyed; a read-only field takes the focus, its text can be selected and copied, never changed. The colours are the field.* component tokens, each an alias of a system role (danger, info, accent.default, warning), checked for contrast over the field.

Sliders take the same states: Slider::new(..).state(state) and RangeSlider::new(..).state(state) draw the edge on the bar and the markers after the label, and give the state to assistive technologies. A read-only slider takes the focus and refuses every change (drag, keys, wheel, typed entry, reset); a disabled one is greyed, skipped by Tab and says its reason on hover. Without a state, a slider is drawn as before.

Agents read every field drawn in the last pass through the debug bridge’s fields collector (and egui_pop_core::field::describe): its label, kind (text, masked, multiline, number, path, search, slider, range), its marks, whether it can be focused and edited, the disabled reason and the invalid message. The same snapshot lists the Tab scopes and their stops.

Any widget can show a state: field::paint_edge, field::paint_markers, field::hover (the tooltips), field::access and field::record.

Tab order

use egui_pop::egui;
use egui_pop::core::input::Input;
use egui_pop::core::tab::{self, ScopeKind, TabStop};

fn options(ui: &mut egui::Ui, tags: &mut String, quality: &mut String) {
    tab::scope(ui, "export-options", ScopeKind::Panel, |ui| {
        Input::text(tags, "Tags").tab(TabStop::new().group("export")).show(ui);
        Input::text(quality, "Quality").tab(TabStop::new().group("export")).show(ui);
        let r = ui.button("Export");
        tab::stop(ui, &r, TabStop::new()); // any widget joins the order
    });
}
  • Reading order by default inside a scope: rows from top to bottom, in a row from left to right, whatever order the widgets were drawn in (two columns drawn one after the other still read row by row).
  • Explicit order: stops with TabStop::index(n) come first, by index; groups (TabStop::group(name)) keep their stops together, at the place of the group’s first stop. The parts of one input (the field, its ✕, its buttons) are a group of their own.
  • Disabled fields are skipped, read-only ones are not.
  • Focus scopes: in a ScopeKind::Modal scope Tab cycles (after the last stop comes the first); in a ScopeKind::Panel scope, Tab past its ends goes on in egui’s order. F6 and Shift+F6 move to the next or previous panel scope, to the stop focused there last (its first the first time); F6 does nothing while a modal is open. In an application, F6 goes through the window’s regions, and a region’s panel scopes take its turn.
KeyWhat it does
Tab, Shift+TabThe next or previous stop of the scope
F6, Shift+F6The next or previous panel, or region
Enter, Space on a ✕ or a buttonPresses it

The order is computed from the stops drawn in the previous pass (egui_pop_model::tab::order, pure and tested), and egui-pop moves the focus before anything is drawn. The focus on a widget that is not a stop is left to egui, whose Tab order is the order of drawing; a focused widget that takes the keys itself (a terminal) keeps Tab and F6.

F6 through the regions

In an application, workbench.next_region (F6) and workbench.previous_region (Shift+F6) go through the parts of the window: the activity bar, the start side area, the end side area, the bottom area, the centre, each palette, an open flyout, the status bar. Tab stays as it is: a region is a focus scope (focus::region), not a Tab scope. They are commands like others, in the palette’s list and rebindable.

  • Where it lands: the widget focused there last; else the one named with focus::prefer; else the first focusable widget of what the region holds (a panel before its dock’s tab, a palette’s field before its band); else, in an area, the panel itself, as workbench.focus does; else whatever else there can take the focus. A region with nothing to land on is passed over.
  • From nothing: the first region, or the last with Shift. After Escape or a press, from the region the user was in, which the focus chain still names.
  • A panel tab::scope takes its region’s turn, one stop of the round each, and F6 goes on out of them. What lies around them in the region is reached by Tab.
  • It does nothing behind a modal, with a menu or a popover open (Escape comes first: F6 would leave it open behind the focus), and for an agent while someone is typing. A flyout stays open as F6 leaves it, like a palette.
  • A focused terminal keeps F6, like every key, for its program; Shift+Escape leaves it.
  • Hidden palettes are no region. Where palettes float and nothing has the focus, Tab still hides them: F6 is the way in, and Tab moves from there.
  • Each window has its own: a detached panel’s window draws no region, so F6 stays there, for the panel scopes it may have.
  • Without an application, focus::region draws a region and regions::next says where F6 goes; a window with no region keeps tab::scope’s F6.

What is no stop

A widget that would show nothing focused and answers no key senses without FOCUSABLE: Sense::CLICK | Sense::DRAG or Sense::DRAG rather than Sense::click_and_drag() or Sense::drag(). egui-pop’s window caption and its flyout’s edge do so. With the focus plugin, Tab passes over the frame of a popup (a menu, a context menu, a combo box’s list), which egui 0.36 makes a stop. A side area’s resize line is still one, as egui draws it.

Keys on a scroll area

UiPop::scroll_area answers the keys egui’s own scroll area does not, and every scroll area of egui-pop’s own goes through it: its panels, dialogs and lists, and the views (scroll_area_viewport and scroll_area_rows are its forms for a view drawing only what is in view). An application’s area on egui::ScrollArea directly has none of this.

KeyMoves it
Page Up, Page DownBy its height less a row
Home, EndTo its start, to its end
The arrowsBy a row, unless a widget inside holds the focus (below)

Pages, Home and End go down the area, or along it when it scrolls only sideways. A move is not animated, whatever the motion setting, and a held key goes on.

  • Which area: the one holding the focus. With nothing focused, the one under the pointer, unless a popup is open. With the focus elsewhere, a key goes nowhere new, as a widget there may be reading it. The innermost goes first; at its end the key goes on to the area around it, as the wheel does.
  • A binding goes first: the dispatcher takes a key that resolves, in whatever scope it is bound, along with what it sends while held.
  • A widget inside goes first: a text input, or a focused widget sensing drags (a slider, a canvas, an editor, a terminal), keeps these keys. So does one naming itself with focus::takes_keys (each pass, as it is drawn): a list, a grid, a row of stars. A view whose focusable widget lies around its area (the list, the tree, the library’s grid) calls it inside the area, which then makes the view the Tab stop rather than itself. Another focused widget (a button, a link) leaves the pages, Home and End to the area, and the arrows to egui, which moves the focus.
  • A Tab stop only when nothing else can be, as a browser’s scroller: an area overflowing, with nothing focusable inside, takes the focus (role ScrollView, named “Scrollable content”), shows the focus.ring around it and has the arrows. An area with nothing to scroll is no stop, and neither is one starting to fit. A click does not focus it; the pointer over it is enough.
  • Not there: an area with hidden bars (ScrollBarVisibility::AlwaysHidden), or scrolling without them (ScrollSource), has no keys, as it has no bar to say which ways it goes. A key with a modifier is not the area’s.

The wheel at a scroll area’s end

At its end a scroll area leaves the wheel to the area around it, as egui does. That suits a plain body, as a sizeable text in a panel should not trap the wheel, but in a list a notch too many moves the panel under the pointer, and the next lands on another widget. So what nests keeps it:

  • The views do so themselves: the list, the tree, the library’s grid, the thumbnail grid, the table, the editor, a section’s body. The terminal takes every wheel over it.
  • An area of yours: ui.scroll_area_contained(area, add) in place of ui.scroll_area, or ui::contain_wheel(ui, &out) after scroll_area_viewport, scroll_area_rows or one you show yourself.
  • Only the ways it can go. A list with nothing to scroll hands the wheel on, and a sideways wheel goes on past an area that only scrolls down. An area with its bars hidden holds nothing, as it has no bar to say which ways it goes.
  • Popups and dialogs need none of this: each is a layer of its own, and what scrolls under it does not see the wheel.
  • A trackpad too: egui 0.37 hands a trackpad at an area’s end on to the area around it rather than stretching the area, and containment keeps it there all the same.

A strip that scrolls only sideways

egui-pop’s themes turn on egui’s always_scroll_the_only_direction: an area that scrolls one way only takes the plain wheel that way, so a strip of tabs or a filmstrip scrolls sideways without Shift, which nobody finds on a strip with no bar. At its end the wheel goes on to the area around it, as for any area. Shift still works.

Trackpads and touch screens

egui 0.37 scrolls a trackpad and a touch drag with momentum: a touch drag coasts after the release, and a trackpad or a touch drag stretches an area past its end and springs back (KineticScrollStyle). A mouse wheel does neither. Under reduced motion (ThemeSpec::reduced_motion) the theme turns both off: an area stops where the finger leaves it, and at its ends. A panel that wants no stretch even with motion on (a column of sliders, say) sets ui.spacing_mut().scroll.kinetic.rubber_band = false before its area.

Arrows stay in their region

With the focus plugin, a plain arrow on a widget that does not read it moves the focus as egui has it, to the nearest widget that way, but not out of the region holding the focus (the parts F6 goes through: a side area, the centre, a palette, the status bar): such a move is undone in the next pass, and the focus stays where it was. Tab and F6 cross regions; a widget outside every region keeps egui’s rule.

A roving group is one stop

tab::roving(ui, name, axis, add) makes what add draws one Tab stop, as ARIA’s toolbar pattern has it: egui-pop’s toolbars are drawn in one.

  • Tab from any of its widgets leaves the group, past its last widget, and Shift+Tab before its first. After Escape, Tab goes on past it too.
  • Tab coming in, either way, lands on the widget focused there last; on the first the first time.
  • The arrows along it (Left and Right in a row, Axis::Horizontal; Up and Down in a column, Axis::Vertical) go to the widget placed before or after, round from one end to the other; Home and End go to its ends. The other arrows are egui’s, and stay in their region.
  • Its widgets are those drawn inside it that can take the focus: a disabled one is passed over. An open menu or popup keeps the arrows, and a focused text field every key.
  • It needs the focus plugin; tab::rovings lists the groups the last pass drew.

A popover keeps Tab

With the focus plugin (focus::install; an application has it), Tab does not walk the window behind an open popover.

  • Past its last stop, Tab comes back to its first, and Shift+Tab from its first goes to its last, as in a dialog. Escape or a click outside is the way out, and the focus goes back to what opened it.
  • From outside it, whether the widget that opened it, another or nothing, Tab goes in at its first stop and Shift+Tab at its last. The widget that opened it is not one of the stops.
  • With no stop in it, it closes, and Tab goes on from where it was.
  • A focused widget taking Tab itself (a terminal, an editor, a text field with lock_focus) keeps the key; Escape or Shift+Escape leaves it first, as anywhere.
  • Which: an overlay of Kind::Popover on top of the stack, the status bar’s popovers and its jobs popover. An egui::Popup used as a popover asks for it with focus::keep_tab(ui) at the end of its content. A menu has its own keys, and a flyout (overlay::hold) stays open as the focus leaves it, like a palette.

The focus keeps its place

With the focus plugin (focus::install; an application has it), the focus remembers the widget it was last on and that widget’s rectangle.

  • Escape, then Tab or Shift+Tab: goes on from that widget. Escape itself still leaves nothing focused. So does a widget disabled while focused.
  • The focused widget is removed: the focus goes to the stop nearest to where it was, in the innermost scope around it that still holds one, else in its layer: the row taking its place, the row before if it was the last, the next tab. A button opening or closing panels may be rebuilt under a new id; it keeps the focus if it stands in the same place.
  • The focused widget scrolled away, or removed by the pointer: the focus goes to nothing and stays out of the way of the wheel, and Tab goes to the visible stop nearest to the place. If the widget is back by then, Tab goes on from it.
  • A key binding on Tab goes first: nothing is focused, so the palettes’ toggle still takes Tab after Escape, and the place waits.
  • Inside a tab::scope, going on from the place follows the order of drawing, not the scope’s reading order.
  • Forgotten: a press on nothing forgets the place; a place under a modal or in a layer now gone (a closed menu) is not used. Tab then does what egui does, from the window’s first stop or its last.

The focus comes into view

With the focus plugin (focus::install; an application has it), a widget the keyboard focuses comes into view in the scroll areas around it, nested ones included, whatever panel it lies in. A widget has nothing to do for it.

  • By anything but the pointer: Tab, an arrow, a command, a screen reader. A click on a half-visible row does not make it jump, in click mode or as the pointer hands the focus over in hover mode.
  • Once per move: the wheel can then take the focused widget away.
  • By the least that shows it, with the item spacing around it. A widget longer than the view stays where it is.
  • Never animated, whatever the motion setting: a key held down has no moving target to chase, and reduced motion asks for nothing more.
  • Windowed rows (show_rows): a row not drawn is no stop. Each row reached scrolls the next one into the drawn window, so Tab goes through them all, one by one, both ways. A list, a tree or a grid from egui-pop-views is one stop and scrolls to its own cursor.
  • Not found: an area with ScrollBarVisibility::AlwaysHidden shows no bar to read its reach from: what it holds calls Response::scroll_to_me on gaining the focus, as the stack of sections does.

How it finds the areas, and why a widget’s own scroll_to_me would not do, is in the upstream register.

A focus you can see

With the focus plugin, the widget the keyboard focused gets a ring of the focus.ring token, painted at the end of the pass on the widget’s layer. egui’s own widgets draw none: a focused button looked like a pressed one.

  • Only by the keyboard: Tab, an arrow, F6, a command, a screen reader. A click focuses without a ring, as GTK’s and Qt’s focus flags and the web’s :focus-visible have it, and the next press of the pointer takes the ring away. focus::ring_shown says which case holds now.
  • Inside the widget: the ring is drawn inside the part of the widget that shows, so it never spills over a panel’s or a scroll area’s edge.
  • Not twice: a widget showing its focus itself calls focus::own_ring each pass it has the focus. One painting a kit state from State::from_response has it said for it, and egui’s text fields, which outline themselves, are left alone. egui-pop’s sliders, fields, views, editors, graph and viewport show their own.

Not yet

  • A formal form layout (labels in a column, sections, help text, inline errors and an error summary, built from value descriptors) and the Form dialog on it come next, with the decision on how components are mounted in hosts.
  • The application shell’s own panels are not Tab scopes: an application wraps a panel’s content in tab::scope for reading order inside it.

Why its own

egui’s TextEdit is the field (with its hint text); nothing in the egui ecosystem draws decorated inputs from tokens, carries a shared field state, or orders Tab per scope. See the survey.