Connor McAdams : oleacc: Add get_accKeyboardShortcut function for edit client accessible object.
Alexandre Julliard
julliard at winehq.org
Mon Sep 27 15:21:45 CDT 2021
Module: wine
Branch: master
Commit: dbdebac3166f79207eef7fcd1ff7d7dfcf725924
URL: https://source.winehq.org/git/wine.git/?a=commit;h=dbdebac3166f79207eef7fcd1ff7d7dfcf725924
Author: Connor McAdams <cmcadams at codeweavers.com>
Date: Mon Sep 27 16:11:09 2021 +0200
oleacc: Add get_accKeyboardShortcut function for edit client accessible object.
Signed-off-by: Connor McAdams <cmcadams at codeweavers.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/oleacc/client.c | 67 ++++++++++++++++++++++++++++++++++++----------------
1 file changed, 47 insertions(+), 20 deletions(-)
diff --git a/dlls/oleacc/client.c b/dlls/oleacc/client.c
index 032f8867d31..6419e8dec31 100644
--- a/dlls/oleacc/client.c
+++ b/dlls/oleacc/client.c
@@ -46,6 +46,7 @@ struct win_class_vtbl {
void (*init)(Client*);
HRESULT (*get_state)(Client*, VARIANT, VARIANT*);
HRESULT (*get_name)(Client*, VARIANT, BSTR*);
+ HRESULT (*get_kbd_shortcut)(Client*, VARIANT, BSTR*);
};
static HRESULT win_get_name(HWND hwnd, BSTR *name)
@@ -69,6 +70,29 @@ static HRESULT win_get_name(HWND hwnd, BSTR *name)
return *name ? S_OK : E_OUTOFMEMORY;
}
+static HRESULT win_get_kbd_shortcut(HWND hwnd, BSTR *shortcut)
+{
+ WCHAR buf[1024];
+ UINT i, len;
+
+ len = SendMessageW(hwnd, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf);
+ if(!len)
+ return S_FALSE;
+
+ for(i=0; i<len; i++) {
+ if(buf[i] == '&')
+ break;
+ }
+ if(i+1 >= len)
+ return S_FALSE;
+
+ *shortcut = SysAllocString(L"Alt+!");
+ if(!*shortcut)
+ return E_OUTOFMEMORY;
+ (*shortcut)[4] = buf[i+1];
+ return S_OK;
+}
+
static inline Client* impl_from_Client(IAccessible *iface)
{
return CONTAINING_RECORD(iface, Client, IAccessible_iface);
@@ -304,32 +328,20 @@ static HRESULT WINAPI Client_get_accHelpTopic(IAccessible *iface,
}
static HRESULT WINAPI Client_get_accKeyboardShortcut(IAccessible *iface,
- VARIANT varID, BSTR *pszKeyboardShortcut)
+ VARIANT id, BSTR *shortcut)
{
Client *This = impl_from_Client(iface);
- WCHAR name[1024];
- UINT i, len;
-
- TRACE("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pszKeyboardShortcut);
- *pszKeyboardShortcut = NULL;
- if(convert_child_id(&varID) != CHILDID_SELF)
- return E_INVALIDARG;
+ TRACE("(%p)->(%s %p)\n", This, debugstr_variant(&id), shortcut);
- 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;
+ *shortcut = NULL;
+ if(This->vtbl && This->vtbl->get_kbd_shortcut)
+ return This->vtbl->get_kbd_shortcut(This, id, shortcut);
- *pszKeyboardShortcut = SysAllocString(L"Alt+!");
- if(!*pszKeyboardShortcut)
- return E_OUTOFMEMORY;
+ if(convert_child_id(&id) != CHILDID_SELF)
+ return E_INVALIDARG;
- (*pszKeyboardShortcut)[4] = name[i+1];
- return S_OK;
+ return win_get_kbd_shortcut(This->hwnd, shortcut);
}
static HRESULT WINAPI Client_get_accFocus(IAccessible *iface, VARIANT *focus)
@@ -744,10 +756,25 @@ static HRESULT edit_get_name(Client *client, VARIANT id, BSTR *name)
return win_get_name(label, name);
}
+static HRESULT edit_get_kbd_shortcut(Client *client, VARIANT id, BSTR *shortcut)
+{
+ HWND label;
+
+ if(convert_child_id(&id) != CHILDID_SELF)
+ return E_INVALIDARG;
+
+ label = edit_find_label(client->hwnd, TRUE);
+ if(!label)
+ return S_FALSE;
+
+ return win_get_kbd_shortcut(label, shortcut);
+}
+
static const win_class_vtbl edit_vtbl = {
edit_init,
edit_get_state,
edit_get_name,
+ edit_get_kbd_shortcut,
};
static const struct win_class_data classes[] = {
More information about the wine-cvs
mailing list