diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-07-14 11:50:17 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-07-18 22:49:53 +0200 |
commit | 3bace699bf6f5a8187e61d2f99b7dcb033c0ea63 (patch) | |
tree | c187bbcb0dc699695ff76057af2ec7baa7158943 /src/gui/accessible | |
parent | 90af40ccd07fda57f966107c5fd8ffcbd955b384 (diff) |
a11y uia: Support ISelectionProvider2
Support UIA's ISelectionProvider2 interface [1]
in addition to ISelectionProvider.
The ISelectionProvider2 interface inherits from the
ISelectionProvider interface.
A follow-up commit that will introduce bridging the
QAccessibleSelectionInterface, introduced in commit
9d16d5e2245c26e5746fd7609300b84a2a983457.
While at it, also reserve space for the amount
of children in the QList in QWindowsUiaSelectionProvider::GetSelection
before inserting them one by one, to avoid reallocations.
Sample use of the ISelectionProvider2 interface from NVDA's
Python console [2] with this commit in place:
1) start NVDA
2) run the gallery example (examples\widgets\gallery\gallery.exe)
3) click on the "Style" listbox at the top
4) press Numpad_insert+control+z to start the NVDA Python console and
capture snapshot variables
5) query and use the interface using NVDA's Python console
>>> import UIAHandler
>>> iselection2 = focus.parent.UIAElement.GetCurrentPattern(10034).QueryInterface(UIAHandler.IUIAutomationSelectionPattern2)
>>> iselection2.CurrentItemCount
1
>>> iselection2.CurrentFirstSelectedItem.CurrentName
'windowsvista'
>>> iselection2.CurrentLastSelectedItem.CurrentName
'windowsvista'
[1] https://learn.microsoft.com/en-us/windows/win32/api/uiautomationcore/nn-uiautomationcore-iselectionprovider2
[2] https://www.nvaccess.org/files/nvda/documentation/developerGuide.html#PythonConsole
Change-Id: I43642e9e39b63c65da97af976cc322a8e5868170
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/gui/accessible')
-rw-r--r-- | src/gui/accessible/windows/apisupport/uiapatternids_p.h | 1 | ||||
-rw-r--r-- | src/gui/accessible/windows/apisupport/uiaserverinterfaces_p.h | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/accessible/windows/apisupport/uiapatternids_p.h b/src/gui/accessible/windows/apisupport/uiapatternids_p.h index 0ff463cd36..676c3fe24e 100644 --- a/src/gui/accessible/windows/apisupport/uiapatternids_p.h +++ b/src/gui/accessible/windows/apisupport/uiapatternids_p.h @@ -49,5 +49,6 @@ #define UIA_DropTargetPatternId 10031 #define UIA_TextEditPatternId 10032 #define UIA_CustomNavigationPatternId 10033 +#define UIA_SelectionPattern2Id 10034 #endif diff --git a/src/gui/accessible/windows/apisupport/uiaserverinterfaces_p.h b/src/gui/accessible/windows/apisupport/uiaserverinterfaces_p.h index 6cf15cacb0..244176921b 100644 --- a/src/gui/accessible/windows/apisupport/uiaserverinterfaces_p.h +++ b/src/gui/accessible/windows/apisupport/uiaserverinterfaces_p.h @@ -236,6 +236,24 @@ __CRT_UUID_DECL(ISelectionProvider, 0xfb8b03af, 0x3bdf, 0x48d4, 0xbd,0x36, 0x1a, #endif #endif +#ifndef __ISelectionProvider2_INTERFACE_DEFINED__ +#define __ISelectionProvider2_INTERFACE_DEFINED__ +DEFINE_GUID(IID_ISelectionProvider2, 0x14f68475, 0xee1c, 0x44f6, 0xa8, 0x69, 0xd2, 0x39, 0x38, 0x1f, 0x0f, 0xe7); +MIDL_INTERFACE("14f68475-ee1c-44f6-a869-d239381f0fe7") +ISelectionProvider2 : public ISelectionProvider +{ +public: + virtual HRESULT STDMETHODCALLTYPE get_FirstSelectedItem(__RPC__deref_out_opt IRawElementProviderSimple **retVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_LastSelectedItem(__RPC__deref_out_opt IRawElementProviderSimple **retVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_CurrentSelectedItem(__RPC__deref_out_opt IRawElementProviderSimple **retVal) = 0; + virtual HRESULT STDMETHODCALLTYPE get_ItemCount(__RPC__out int *retVal) = 0; +}; + +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(ISelectionProvider2, 0x14f68475, 0xee1c, 0x44f6, 0xa8, 0x69, 0xd2, 0x39, 0x38, 0x1f, 0x0f, 0xe7) +#endif +#endif + #ifndef __ISelectionItemProvider_INTERFACE_DEFINED__ #define __ISelectionItemProvider_INTERFACE_DEFINED__ |