From cdb1a164de06f18cad497409a514f270a8336b4c Mon Sep 17 00:00:00 2001 From: Matt Campbell Date: Mon, 14 Nov 2022 13:45:56 -0600 Subject: [PATCH] feat(platforms/winit): Allow a custom action handler (#149) --- platforms/winit/src/lib.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/platforms/winit/src/lib.rs b/platforms/winit/src/lib.rs index 0ae64bc1d..566d35ce3 100644 --- a/platforms/winit/src/lib.rs +++ b/platforms/winit/src/lib.rs @@ -47,7 +47,19 @@ impl Adapter { window_id: window.id(), proxy: Mutex::new(event_loop_proxy), }; - let adapter = platform_impl::Adapter::new(window, source, Box::new(action_handler)); + Self::with_action_handler(window, source, Box::new(action_handler)) + } + + /// Use this if you need to provide your own AccessKit action handler + /// rather than dispatching action requests through the winit event loop. + /// Remember that an AccessKit action handler can be called on any thread, + /// depending on the underlying AccessKit platform adapter. + pub fn with_action_handler( + window: &Window, + source: Box TreeUpdate + Send>, + action_handler: Box, + ) -> Self { + let adapter = platform_impl::Adapter::new(window, source, action_handler); Self { adapter } }