pub struct Adapter { /* private fields */ }
Implementations§
Source§impl Adapter
impl Adapter
Sourcepub fn with_event_loop_proxy<T: From<Event> + Send + 'static>(
event_loop: &ActiveEventLoop,
window: &Window,
proxy: EventLoopProxy<T>,
) -> Self
pub fn with_event_loop_proxy<T: From<Event> + Send + 'static>( event_loop: &ActiveEventLoop, window: &Window, proxy: EventLoopProxy<T>, ) -> Self
Creates a new AccessKit adapter for a winit window. This must be done
before the window is shown for the first time. This means that you must
use winit::window::WindowAttributes::with_visible
to make the window
initially invisible, then create the adapter, then show the window.
This constructor uses a winit event loop proxy to deliver AccessKit
events to the main event loop. The primary disadvantage of this approach
is that it’s not possible to synchronously return an initial tree
in response to the WindowEvent::InitialTreeRequested
event,
so some platform adapters will have to use a temporary placeholder tree
until you send the first update. For an optimal implementation,
consider using Adapter::with_direct_handlers
or
Adapter::with_mixed_handlers
instead.
§Panics
Panics if the window is already visible.
Sourcepub fn with_direct_handlers(
event_loop: &ActiveEventLoop,
window: &Window,
activation_handler: impl 'static + ActivationHandler + Send,
action_handler: impl 'static + ActionHandler + Send,
deactivation_handler: impl 'static + DeactivationHandler + Send,
) -> Self
pub fn with_direct_handlers( event_loop: &ActiveEventLoop, window: &Window, activation_handler: impl 'static + ActivationHandler + Send, action_handler: impl 'static + ActionHandler + Send, deactivation_handler: impl 'static + DeactivationHandler + Send, ) -> Self
Creates a new AccessKit adapter for a winit window. This must be done
before the window is shown for the first time. This means that you must
use winit::window::WindowAttributes::with_visible
to make the window
initially invisible, then create the adapter, then show the window.
Use this if you want to provide your own AccessKit handler callbacks rather than dispatching requests through the winit event loop. This is especially useful for the activation handler, because depending on your application’s architecture, implementing the handler directly may allow you to return an initial tree synchronously, rather than requiring some platform adapters to use a placeholder tree until you send the first update. However, remember that each of these handlers may be called on any thread, depending on the underlying platform adapter.
§Panics
Panics if the window is already visible.
Sourcepub fn with_mixed_handlers<T: From<Event> + Send + 'static>(
event_loop: &ActiveEventLoop,
window: &Window,
activation_handler: impl 'static + ActivationHandler + Send,
proxy: EventLoopProxy<T>,
) -> Self
pub fn with_mixed_handlers<T: From<Event> + Send + 'static>( event_loop: &ActiveEventLoop, window: &Window, activation_handler: impl 'static + ActivationHandler + Send, proxy: EventLoopProxy<T>, ) -> Self
Creates a new AccessKit adapter for a winit window. This must be done
before the window is shown for the first time. This means that you must
use winit::window::WindowAttributes::with_visible
to make the window
initially invisible, then create the adapter, then show the window.
This constructor provides a mix of the approaches used by
Adapter::with_event_loop_proxy
and Adapter::with_direct_handlers
.
It uses the event loop proxy for the action request and deactivation
events, which can be handled asynchronously with no drawback,
while using a direct, caller-provided activation handler that can
return the initial tree synchronously. Remember that the thread on which
the activation handler is called is platform-dependent.
§Panics
Panics if the window is already visible.
Sourcepub fn process_event(&mut self, window: &Window, event: &WinitWindowEvent)
pub fn process_event(&mut self, window: &Window, event: &WinitWindowEvent)
Allows reacting to window events.
This must be called whenever a new window event is received and before it is handled by the application.
Sourcepub fn update_if_active(&mut self, updater: impl FnOnce() -> TreeUpdate)
pub fn update_if_active(&mut self, updater: impl FnOnce() -> TreeUpdate)
If and only if the tree has been initialized, call the provided function
and apply the resulting update. Note: If the caller’s implementation of
ActivationHandler::request_initial_tree
initially returned None
,
or if the caller created the adapter using EventLoopProxy
, then
the TreeUpdate
returned by the provided function must contain
a full tree.
Auto Trait Implementations§
impl Freeze for Adapter
impl RefUnwindSafe for Adapter
impl Send for Adapter
impl Sync for Adapter
impl Unpin for Adapter
impl UnwindSafe for Adapter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.