pub struct Adapter { /* private fields */ }
Implementations§
Source§impl Adapter
impl Adapter
Sourcepub fn new(
hwnd: HWND,
is_window_focused: bool,
action_handler: impl 'static + ActionHandler + Send,
) -> Self
pub fn new( hwnd: HWND, is_window_focused: bool, action_handler: impl 'static + ActionHandler + Send, ) -> Self
Creates a new Windows platform adapter.
The action handler may or may not be called on the thread that owns the window.
This must not be called while handling the WM_GETOBJECT
message,
because this function must initialize UI Automation before
that message is handled. This is necessary to prevent a race condition
that leads to nested WM_GETOBJECT
messages and, in some cases,
assistive technologies not realizing that the window natively implements.
UIA. See AccessKit issue #37
for more details.
Sourcepub fn update_if_active(
&mut self,
update_factory: impl FnOnce() -> TreeUpdate,
) -> Option<QueuedEvents>
pub fn update_if_active( &mut self, update_factory: impl FnOnce() -> TreeUpdate, ) -> Option<QueuedEvents>
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
,
the TreeUpdate
returned by the provided function must contain
a full tree.
If a QueuedEvents
instance is returned, the caller must call
QueuedEvents::raise
on it.
This method may be safely called on any thread, but refer to
QueuedEvents::raise
for restrictions on the context in which
it should be called.
Sourcepub fn update_window_focus_state(
&mut self,
is_focused: bool,
) -> Option<QueuedEvents>
pub fn update_window_focus_state( &mut self, is_focused: bool, ) -> Option<QueuedEvents>
Update the tree state based on whether the window is focused.
If a QueuedEvents
instance is returned, the caller must call
QueuedEvents::raise
on it.
This method may be safely called on any thread, but refer to
QueuedEvents::raise
for restrictions on the context in which
it should be called.
Sourcepub fn handle_wm_getobject<H: ActivationHandler + ?Sized>(
&mut self,
wparam: WPARAM,
lparam: LPARAM,
activation_handler: &mut H,
) -> Option<impl Into<LRESULT>>
pub fn handle_wm_getobject<H: ActivationHandler + ?Sized>( &mut self, wparam: WPARAM, lparam: LPARAM, activation_handler: &mut H, ) -> Option<impl Into<LRESULT>>
Handle the WM_GETOBJECT
window message. The accessibility tree
is lazily initialized if necessary using the provided
ActivationHandler
implementation.
This returns an Option
so the caller can pass the message
to DefWindowProc
if AccessKit decides not to handle it.
The optional value is an Into<LRESULT>
rather than simply an LRESULT
so the necessary call to UIA, which may lead to a nested WM_GETOBJECT
message, can be done outside of any lock that the caller might hold
on the Adapter
or window state, while still abstracting away
the details of that call to UIA.