1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

Lazily activate egui's AccessKit support

This commit is contained in:
Matt Campbell
2022-11-29 16:21:26 -06:00
parent 9473dbdde1
commit 2114978e9b
7 changed files with 150 additions and 102 deletions

View File

@@ -132,10 +132,21 @@ impl State {
&mut self,
window: &winit::window::Window,
event_loop_proxy: winit::event_loop::EventLoopProxy<T>,
egui_ctx: egui::Context,
) {
self.accesskit = Some(accesskit_winit::Adapter::new(
window,
Box::new(egui::accesskit_placeholder_tree_update),
Box::new(move || {
// This function is called when an accessibility client
// (e.g. screen reader) makes its first request. If we got here,
// we know that an accessibility tree is actually wanted.
// Tell egui that AccessKit is active, and return a placeholder
// tree for now. `egui::Context::accesskit_activated`
// will request a repaint, and that will provide the first
// real accessibility tree.
egui_ctx.accesskit_activated();
egui::accesskit_placeholder_tree_update()
}),
event_loop_proxy,
));
}
@@ -645,10 +656,8 @@ impl State {
}
#[cfg(feature = "accesskit")]
{
if let Some(accesskit) = self.accesskit.as_ref() {
accesskit.update(accesskit_update);
}
if let Some(accesskit) = self.accesskit.as_ref() {
accesskit.update_if_active(|| accesskit_update);
}
}