Skip to main content

Module regions

Module regions 

Source
Expand description

F6 through a window’s regions: the parts of the window (an area, a palette, the status bar), each a focus::region.

next says where the keyboard goes; whoever binds F6 moves it there (an application: the commands workbench.next_region and workbench.previous_region). It changes no Tab order: a region is a focus scope, not a tab::scope.

  • The order is the regions’ ranks, and it wraps. From nothing it starts at the first, or the last going back; after Escape or a press, nothing holds the focus and the focus chain still says where the user is, so it goes on from that region.
  • Where it lands: the widget focused there last, if it can still take the focus; else the one the region names with focus::prefer; else the first focusable widget of a scope inside the region, the content before what stands around it (a dock’s tabs, a palette’s band); else nowhere, for a Region::holding, whose content then holds the focus itself; else any focusable widget of the region in view. A region with nothing to land on is passed over.
  • Panel tab::scopes of a region take that region’s turn, each a stop of the round, at the stop focused there last or its first; what lies around them is reached by Tab. F6 goes on out of them.
  • Nothing moves behind a modal, overlay or scope.
  • A focused widget taking every key (a terminal) gets F6 before any binding does.
  • Each window has its own regions, as it has its own focus.

upstream: egui lists no focusable widgets, but its widget rectangles carry each widget’s sense in the order drawn, as a scope’s widgets are recorded; the last pass’s are enough to choose from before anything is drawn.

use egui_pop_core::{focus, regions};

fn window(ui: &mut egui::Ui) {
    focus::region(ui, &focus::Region::new("list", 0), |ui| {
        let _ = ui.button("Row");
    });
    focus::region(ui, &focus::Region::new("status", 1), |ui| {
        let _ = ui.button("Item");
    });
    if ui.input(|i| i.key_pressed(egui::Key::F6))
        && let Some(regions::Hop { target: Some(id), .. }) = regions::next(ui.ctx(), false)
    {
        ui.memory_mut(|m| m.request_focus(id));
    }
}

Structs§

Hop
Where F6 goes.

Functions§

next
The next region’s landing, or the previous one’s with back. None behind a modal, or with nowhere to go.