Skip to content

Commit

Permalink
feat(platforms/winit): Allow a custom action handler (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcampbell authored Nov 14, 2022
1 parent 3f372d5 commit cdb1a16
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion platforms/winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn FnOnce() -> TreeUpdate + Send>,
action_handler: Box<dyn ActionHandler>,
) -> Self {
let adapter = platform_impl::Adapter::new(window, source, action_handler);
Self { adapter }
}

Expand Down

0 comments on commit cdb1a16

Please sign in to comment.