Skip to main content

Module inspect

Module inspect 

Source
Expand description

The element picker behind devtools’ inspect mode: while it is on, the widget under the pointer is outlined with a small label, a click picks it instead of reaching it, Tab and the arrows move between widgets and Enter picks, Escape leaves. A pick says what egui knows of the widget (Pick); the application side (egui_pop_api’s devtools) adds what it knows and shows it.

The hit test reads the widget rectangles of the pass just drawn (egui’s ViewportState::this_pass), in every window: the top-most layer holding a rectangle under the point, then the smallest such rectangle, the one drawn last on a tie. Every Ui registers a rectangle, so what paints without one of its own (a custom-painted cell, a mark on a canvas) is named by its nearest container, and the pick says so (kind: "container"). Names, roles and values come from the AccessKit tree of the same pass, switched on while the mode is.

What draws a widget is recorded only while a context inspects: region (a zone’s block, a panel: what the application side records around what it draws) and the kit’s parts painted through a component’s handler (with the state their box was taken in).

use egui_pop_core::inspect;

let ctx = egui::Context::default();
inspect::start(&ctx);
assert!(inspect::active(&ctx));
inspect::stop(&ctx);
assert!(!inspect::active(&ctx));

Structs§

KitPart
A part painted through a kit component’s handler.
Pick
What the picker knows of a widget.
Region
A part of the interface the application drew around what it holds (a zone’s block, a panel), recorded while a context inspects.

Functions§

active
Whether the mode is on.
arm
Gives the platform’s copy chord with Shift back as a key (Ctrl+Shift+C under egui-winit, which turns it into a copy event and swallows the key) while on: the devtools setting is, and the mode is bound to that chord.
hex
A colour as #rrggbbaa.
last
The last pick.
pass_through
Lets a press on rect of the window being drawn reach egui while the mode is on, instead of picking: the control toggling the mode (a menu bar button) then leaves it. Call it each pass the control is drawn.
region
Records a part of the interface around what ui drew (call it once drawn): a zone’s block or a panel, with the plugin owning it. Does nothing unless the mode is on.
start
Starts the mode in every window of ctx.
state_name
A kit state’s name: its flags joined with +, or rest.
stop
Leaves the mode.
take_left
Whether the mode was left (Escape, a pick) since the last call.
take_picked
The pick made since the last call, if any.