Announce pressed state of selectable buttons to screen readers#8130
Open
antoinecellerier wants to merge 1 commit into
Open
Announce pressed state of selectable buttons to screen readers#8130antoinecellerier wants to merge 1 commit into
antoinecellerier wants to merge 1 commit into
Conversation
`Button`'s `selected` field is now `Option<bool>`, which lets a plain `Button` (no `.selected(...)` call) stay un-announced while a button that opted in via `.selected(true)` / `.selected(false)` reports its toggled state to assistive technologies. No public API signature changes; `Button::selectable` and `Ui::selectable_label` inherit the behavior automatically. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Preview is being built... Preview will be available at https://egui-pr-preview.github.io/pr/8130-button-accesskit-toggled View snapshot changes at kitdiff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
Buttonused as a toggle (viaButton::selected(true),Button::selectable(...), orUi::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.Checkboxand the pre-existing selectable-label code path already did this;Buttonwas 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 becomesOption<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_apppulls ineframewithdefault-features = falseand doesn't re-enableaccesskit, socargo run -p egui_demo_apppublishes no AccessKit tree at all. To verify manually:cargo run -p egui_demo_app --features accessibility_inspectorHappy to send a small follow-up PR enabling
accesskitin 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.