egui/crates
Juan Campa e0561e1820 Add `Plugin::on_widget_under_pointer` to support widget inspector (#7652)
This PR adds `Plugin::on_widget_under_pointer` which gets called
whenever a widget is created whose rect contains the pointer.

The point of the hook is to capture a stack trace which can be used to
map widgets to their corresponding source code so it must be called
while the widget is being created. The obvious concern is performance
impact. However, since it's only called for rects under the cursor, the
effect seems negligible afaict. It's under `debug_assertions` just in
case.

This change is needed so we can publish the widget inspector we've been
working on. Basically a plugin that allows us to jump from any widget
back to their corresponding source code.

This video shows the plugin configured to open the corresponding code in
github, but normally it would open your local editor.

Update: [Live demo](https://membrane-io.github.io/egui/) (Firefox/Safari
not yet supported. `Cmd-I` to inspect. `Tab` to cycle filters. `Click`
to open). It will try to open a file under
`/home/runner/work/egui/egui/` so it won't work, but you get the idea.


https://github.com/user-attachments/assets/afe4d6af-7f67-44b5-be25-44f7564d9a3a

## What's next

After this gets merged I plan to publish the above plugin as its own
crate, that way we can iterate and release quickly while things are
still changing. I agree it would make sense to eventually merge it into
the main egui repo (like @emilk suggested in #4650).

* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2025-11-13 11:52:19 +01:00
..
ecolor Merge branch 'main' into release-0.33.0 2025-10-09 15:51:02 +02:00
eframe Merge branch 'main' into release-0.33.0 2025-10-09 15:51:02 +02:00
egui Add `Plugin::on_widget_under_pointer` to support widget inspector (#7652) 2025-11-13 11:52:19 +01:00
egui-wgpu Merge branch 'main' into release-0.33.0 2025-10-09 15:51:02 +02:00
egui-winit Don't enable `arboard` on iOS (#7663) 2025-11-13 11:47:53 +01:00
egui_demo_app Add `taplo.toml` for toml formatting (#7618) 2025-10-09 15:38:00 +02:00
egui_demo_lib Fix kerning snapshot test directory 2025-11-13 11:47:25 +01:00
egui_extras Merge branch 'main' into release-0.33.0 2025-10-09 15:51:02 +02:00
egui_glow Merge branch 'main' into release-0.33.0 2025-10-09 15:51:02 +02:00
egui_kittest Release egui_kittest 0.33.1 2025-11-13 11:47:53 +01:00
egui_plot Move `egui_plot` to its own repo (#4828) 2024-07-15 18:45:19 +02:00
egui_web Rename `master` branch to `main` (#7034) 2025-05-08 09:15:42 +02:00
emath Update changelogs 2025-10-09 14:23:58 +02:00
epaint Merge branch 'main' into release-0.33.0 2025-10-09 15:51:02 +02:00
epaint_default_fonts Update changelogs 2025-10-09 14:23:58 +02:00