mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
A `Button` used as a toggle (via `Button::selected(true)`, `Button::selectable(...)`, or `Ui::selectable_label`) now announces its pressed / not-pressed state to screen readers. Plain buttons that never call `.selected(...)` stay un-toggled, so their announcement doesn't change. `Checkbox` and the pre-existing selectable-label code path already did this; `Button` was the odd one out. No public API change: the field is private, `Button::selected(bool)` keeps its signature, and visuals are identical. Internally the field becomes `Option<bool>` so we can distinguish "plain button" from "toggle button currently off". Regression test added in `regression_tests.rs`, do let me know if some other file would be a better location. ### Note for manual testing `egui_demo_app` pulls in `eframe` with `default-features = false` and doesn't re-enable `accesskit`, so `cargo run -p egui_demo_app` publishes no AccessKit tree at all. To verify manually: `cargo run -p egui_demo_app --features accessibility_inspector` Happy to send a small follow-up PR enabling `accesskit` in the demo app's defaults if that's desirable, since that makes a11y work much easier to smoke-test locally. ### Use of AI This PR was drafted with Claude Code. I understand different projects have different policies regarding AI generated code. Do let me know if this is not acceptable here. Also happy to take any other feedback. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>