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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user