diff --git a/Cargo.lock b/Cargo.lock index 2ed4e115e6b..a26ccee6777 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,7 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "accesskit" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ac5b518d65f20dc920b3a7bb92bb2b90cdb301416f27c2a55a128cd99f75c0c" +version = "0.16.0" dependencies = [ "enumn", "serde", @@ -30,9 +28,7 @@ dependencies = [ [[package]] name = "accesskit_atspi_common" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3869678048c6c1eb71b2c91c17be99edae309f88ead11ee96c831d9144ce9201" +version = "0.9.0" dependencies = [ "accesskit", "accesskit_consumer", @@ -44,9 +40,7 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17fa06310c6256253ef3474cb4694346222b4bca85a53aec7f796a73d18e7082" +version = "0.24.0" dependencies = [ "accesskit", "immutable-chunkmap", @@ -54,9 +48,7 @@ dependencies = [ [[package]] name = "accesskit_macos" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a3c2a5bb8b5e403502faff2bbb85de5c14bb822a0ba7e9561cb5229b42a176" +version = "0.17.0" dependencies = [ "accesskit", "accesskit_consumer", @@ -68,9 +60,7 @@ dependencies = [ [[package]] name = "accesskit_unix" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e60feaa57f707d53047f508b55074e904126bf71f916c21d940ac0d8b40333" +version = "0.12.0" dependencies = [ "accesskit", "accesskit_atspi_common", @@ -84,11 +74,19 @@ dependencies = [ "zbus", ] +[[package]] +name = "accesskit_web" +version = "0.1.0" +dependencies = [ + "accesskit", + "accesskit_consumer", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "accesskit_windows" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ab7baf1a8adacddc2c5a4f14d1f936f73a0f0e1c6d4592514992c4d4c57743" +version = "0.22.0" dependencies = [ "accesskit", "accesskit_consumer", @@ -99,13 +97,12 @@ dependencies = [ [[package]] name = "accesskit_winit" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7490b3beef9621c28bbe306abbcb7560a6591444bc498f9b9f6637e1ed8783" +version = "0.22.0" dependencies = [ "accesskit", "accesskit_macos", "accesskit_unix", + "accesskit_web", "accesskit_windows", "raw-window-handle 0.6.2", "winit", @@ -1172,6 +1169,7 @@ dependencies = [ name = "eframe" version = "0.27.2" dependencies = [ + "accesskit_web", "ahash", "bytemuck", "directories-next", diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index d29053aeef7..bb3e397a83a 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -42,7 +42,7 @@ default = [ ] ## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/). -accesskit = ["egui/accesskit", "egui-winit/accesskit"] +accesskit = ["accesskit_web", "egui/accesskit", "egui-winit/accesskit"] # Allow crates to choose an android-activity backend via Winit # - It's important that most applications should not have to depend on android-activity directly, and can @@ -246,6 +246,7 @@ web-sys = { workspace = true, features = [ ] } # optional web: +accesskit_web = { path = "../../../accesskit/platforms/web", optional = true } egui-wgpu = { workspace = true, optional = true } # if wgpu is used, use it without (!) winit wgpu = { workspace = true, optional = true, features = [ # Let's enable some backends so that users can use `eframe` out-of-the-box diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index f8b7f14a9da..6c0d815879f 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -1,9 +1,19 @@ +#[cfg(feature = "accesskit")] +use egui::accesskit; use egui::TexturesDelta; use crate::{epi, App}; use super::{now_sec, text_agent::TextAgent, web_painter::WebPainter, NeedRepaint}; +#[cfg(feature = "accesskit")] +struct StubActionHandler {} + +#[cfg(feature = "accesskit")] +impl accesskit::ActionHandler for StubActionHandler { + fn do_action(&mut self, _request: accesskit::ActionRequest) {} +} + pub struct AppRunner { #[allow(dead_code)] web_options: crate::WebOptions, @@ -20,6 +30,8 @@ pub struct AppRunner { // Output for the last run: textures_delta: TexturesDelta, clipped_primitives: Option>, + #[cfg(feature = "accesskit")] + accesskit: accesskit_web::Adapter, } impl Drop for AppRunner { @@ -114,6 +126,12 @@ impl AppRunner { let mut runner = Self { web_options, frame, + #[cfg(feature = "accesskit")] + accesskit: accesskit_web::Adapter::new( + canvas_id, + egui_ctx.clone(), + StubActionHandler {}, + ), egui_ctx, painter, input: Default::default(), @@ -253,7 +271,7 @@ impl AppRunner { mutable_text_under_cursor, ime, #[cfg(feature = "accesskit")] - accesskit_update: _, // not currently implemented + accesskit_update, } = platform_output; super::set_cursor_icon(cursor_icon); @@ -277,6 +295,11 @@ impl AppRunner { super::string_from_js_value(&err) ); } + + #[cfg(feature = "accesskit")] + if let Some(update) = accesskit_update { + self.accesskit.update_if_active(|| update); + } } }