Bevy Accessibility #11044
Replies: 3 comments 8 replies
-
Beta Was this translation helpful? Give feedback.
-
Ok, so I tried to reproduce the problem. Indeed, for me Orca doesn't announce anything (not even "App") when I try to run the button example. I looked through the Notably, I might also be misusing Orca, as I don't have any screen reader experience. Maybe @ndarilek knows if there are any additional steps needed, to my knowledge they also work with a screen reader and implemented the access kit integration. |
Beta Was this translation helpful? Give feedback.
-
Hmm, interesting, and you're using object nav under Windows and NVDA? Since bevy_ui has no robust concept of focus or keyboard controls, the only way to currently navigate bevy_ui-based UIs with accessibility is via object nav, which should work but is a bit clunky. The goal of the existing accesskit support is just getting it into the engine and making it easy to push updates to the tree for when bevy_ui gains the more advanced concepts needed to make it more pleasant to use. As far as Linux support goes, you'll need to enable a feature (I forget the exact name now) and I don't even think Orca mainline is even supported. The Linux a11y APIs are going through a bit of a revision ATM and I think AccessKit only supports experimental forks of the necessary APIs. Windows and mac are the only platforms I've tested personally. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, so I just started using Bevy today so it's entirely possible that I'm doing something silly but I can't figure out how to make buttons accessible to screen readers. As far as I read Bevy should work with screen readers on most major platforms because of it's access kit integration from earlier this year.
I'm using the button example code like below:
`
//! This example illustrates how to create a button that changes color and text based on its
//! interaction state.
// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind
// type aliases tends to obfuscate code while offering no improvement in code cleanliness.
#![allow(clippy::type_complexity)]
use bevy::{prelude::*, winit::WinitSettings};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
// Only run the app when there is user input. This will significantly reduce CPU/GPU use.
.insert_resource(WinitSettings::desktop_app())
.add_systems(Startup, setup)
.add_systems(Update, button_system)
.run();
}
const NORMAL_BUTTON: Color = Color::rgb(0.15, 0.15, 0.15);
const HOVERED_BUTTON: Color = Color::rgb(0.25, 0.25, 0.25);
const PRESSED_BUTTON: Color = Color::rgb(0.35, 0.75, 0.35);
fn button_system(
mut interaction_query: Query<
(
&Interaction,
&mut BackgroundColor,
&mut BorderColor,
&Children,
),
(Changed, With),
>,
mut text_query: Query<&mut Text>,
) {
for (interaction, mut color, mut border_color, children) in &mut interaction_query {
let mut text = text_query.get_mut(children[0]).unwrap();
match *interaction {
Interaction::Pressed => {
text.sections[0].value = "Press".to_string();
*color = PRESSED_BUTTON.into();
border_color.0 = Color::RED;
}
Interaction::Hovered => {
text.sections[0].value = "Hover".to_string();
*color = HOVERED_BUTTON.into();
border_color.0 = Color::WHITE;
}
Interaction::None => {
text.sections[0].value = "Button".to_string();
*color = NORMAL_BUTTON.into();
border_color.0 = Color::BLACK;
}
}
}
}
fn setup(mut commands: Commands, asset_server: Res) {

// ui camera
commands.spawn(Camera2dBundle::default());
commands
.spawn(NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..default()
},
..default()
})
.with_children(|parent| {
parent
.spawn(ButtonBundle {
style: Style {
width: Val::Px(150.0),
height: Val::Px(65.0),
border: UiRect::all(Val::Px(5.0)),
// horizontally center child text
justify_content: JustifyContent::Center,
// vertically center child text
align_items: AlignItems::Center,
..default()
},
border_color: BorderColor(Color::BLACK),
background_color: NORMAL_BUTTON.into(),
..default()
})
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Button",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 40.0,
color: Color::rgb(0.9, 0.9, 0.9),
},
));
});
});
}
`
When I run it using cargo run I get the following screen:
They only thing that NVDA says is app so I'm not sure what is going wrong here.
Any help would be apreciated.
Note:
I'm running Windows 11 with the latest version of NVDA.
Beta Was this translation helpful? Give feedback.
All reactions