[PATCH v2 4/7] oleacc: Add get_kbd_shortcut function for edit client accessible object.
Connor McAdams
cmcadams at codeweavers.com
Wed Sep 22 15:12:38 CDT 2021
Signed-off-by: Connor McAdams <cmcadams at codeweavers.com>
---
dlls/oleacc/client.c | 57 ++++++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 13 deletions(-)
diff --git a/dlls/oleacc/client.c b/dlls/oleacc/client.c
index 24dc1879142..9d5da15e624 100644
--- a/dlls/oleacc/client.c
+++ b/dlls/oleacc/client.c
@@ -45,6 +45,7 @@ typedef struct {
struct win_class_vtbl {
HRESULT (*get_state)(Client *, INT *);
HRESULT (*get_name)(Client *, BSTR *);
+ HRESULT (*get_kbd_shortcut)(Client *, BSTR *);
};
static HRESULT acc_client_get_name_str(WCHAR *name, UINT len, BSTR *pszName)
@@ -66,6 +67,26 @@ static HRESULT acc_client_get_name_str(WCHAR *name, UINT len, BSTR *pszName)
return *pszName ? S_OK : E_OUTOFMEMORY;
}
+static HRESULT acc_client_get_kbd_shortcut_str(WCHAR *name, UINT len,
+ BSTR *pszKeyboardShortcut)
+{
+ UINT i;
+
+ for(i=0; i<len; i++) {
+ if(name[i] == '&')
+ break;
+ }
+ if(i+1 >= len)
+ return S_FALSE;
+
+ *pszKeyboardShortcut = SysAllocString(L"Alt+!");
+ if(!*pszKeyboardShortcut)
+ return E_OUTOFMEMORY;
+
+ (*pszKeyboardShortcut)[4] = name[i+1];
+ return S_OK;
+}
+
static inline Client* impl_from_Client(IAccessible *iface)
{
return CONTAINING_RECORD(iface, Client, IAccessible_iface);
@@ -307,7 +328,7 @@ static HRESULT WINAPI Client_get_accKeyboardShortcut(IAccessible *iface,
{
Client *This = impl_from_Client(iface);
WCHAR name[1024];
- UINT i, len;
+ UINT len;
TRACE("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszKeyboardShortcut);
@@ -315,20 +336,12 @@ static HRESULT WINAPI Client_get_accKeyboardShortcut(IAccessible *iface,
if(convert_child_id(&varID) != CHILDID_SELF)
return E_INVALIDARG;
- len = SendMessageW(This->hwnd, WM_GETTEXT, ARRAY_SIZE(name), (LPARAM)name);
- for(i=0; i<len; i++) {
- if(name[i] == '&')
- break;
- }
- if(i+1 >= len)
- return S_FALSE;
+ if (This->vtbl && This->vtbl->get_kbd_shortcut)
+ return This->vtbl->get_kbd_shortcut(This, pszKeyboardShortcut);
- *pszKeyboardShortcut = SysAllocString(L"Alt+!");
- if(!*pszKeyboardShortcut)
- return E_OUTOFMEMORY;
+ len = SendMessageW(This->hwnd, WM_GETTEXT, ARRAY_SIZE(name), (LPARAM)name);
- (*pszKeyboardShortcut)[4] = name[i+1];
- return S_OK;
+ return acc_client_get_kbd_shortcut_str(name, len, pszKeyboardShortcut);
}
static HRESULT WINAPI Client_get_accFocus(IAccessible *iface, VARIANT *focus)
@@ -769,9 +782,27 @@ static HRESULT edit_get_name(Client *client, BSTR *out_name)
return acc_client_get_name_str(name, len, out_name);
}
+static HRESULT edit_get_kbd_shortcut(Client *client, BSTR *out_kbd_shortcut)
+{
+ WCHAR name[1024];
+ HWND label;
+ UINT len;
+
+ TRACE("(%p, %p)\n", client, out_kbd_shortcut);
+
+ label = acc_edit_find_label(client->hwnd, TRUE);
+ if(!label)
+ return S_FALSE;
+
+ len = SendMessageW(label, WM_GETTEXT, ARRAY_SIZE(name), (LPARAM)name);
+
+ return acc_client_get_kbd_shortcut_str(name, len, out_kbd_shortcut);
+}
+
const win_class_vtbl edit_class_vtbl = {
edit_get_state,
edit_get_name,
+ edit_get_kbd_shortcut,
};
HRESULT create_edit_client_object(HWND hwnd, const IID *iid, void **obj)
--
2.25.1
More information about the wine-devel
mailing list