mirror of
https://github.com/reactos/reactos.git
synced 2025-05-06 18:31:26 +00:00
[BROWSEUI] Enable Address bar access key (Alt+D) (#6534)
Retrial of #5052. Improve keyboard interface usability. JIRA issue: CORE-18823 - Add GetAddressBarAccessKey helper function to get the accelerator of Address bar from resource string IDS_ADDRESSBANDLABEL. - Implement Alt+D (or something) accelerator in CAddressBand:: TranslateAcceleratorIO method by handling WM_SYSKEYDOWN and WM_SYSCHAR messages.
This commit is contained in:
parent
a08b83a90b
commit
8209aa528b
1 changed files with 58 additions and 0 deletions
|
@ -259,8 +259,66 @@ HRESULT STDMETHODCALLTYPE CAddressBand::HasFocusIO()
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static WCHAR GetAccessKeyFromText(WCHAR chAccess, LPCWSTR pszText)
|
||||||
|
{
|
||||||
|
for (const WCHAR *pch = pszText; *pch != UNICODE_NULL; ++pch)
|
||||||
|
{
|
||||||
|
if (*pch == L'&' && pch[1] == L'&')
|
||||||
|
{
|
||||||
|
/* Skip the first '&', the second is skipped by the for-loop */
|
||||||
|
++pch;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*pch == L'&')
|
||||||
|
{
|
||||||
|
++pch;
|
||||||
|
chAccess = *pch;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::CharUpperBuffW(&chAccess, 1);
|
||||||
|
return chAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
static WCHAR GetAddressBarAccessKey(WCHAR chAccess)
|
||||||
|
{
|
||||||
|
static WCHAR s_chCache = 0;
|
||||||
|
static LANGID s_ThreadLocale = 0;
|
||||||
|
if (s_chCache && s_ThreadLocale == ::GetThreadLocale())
|
||||||
|
return s_chCache;
|
||||||
|
|
||||||
|
WCHAR szText[80];
|
||||||
|
if (!LoadStringW(_AtlBaseModule.GetResourceInstance(), IDS_ADDRESSBANDLABEL,
|
||||||
|
szText, _countof(szText)))
|
||||||
|
{
|
||||||
|
return chAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_chCache = GetAccessKeyFromText(chAccess, szText);
|
||||||
|
s_ThreadLocale = ::GetThreadLocale();
|
||||||
|
return s_chCache;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CAddressBand::TranslateAcceleratorIO(LPMSG lpMsg)
|
HRESULT STDMETHODCALLTYPE CAddressBand::TranslateAcceleratorIO(LPMSG lpMsg)
|
||||||
{
|
{
|
||||||
|
// Enable Address bar access key (Alt+D)
|
||||||
|
switch (lpMsg->message)
|
||||||
|
{
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
case WM_SYSCHAR:
|
||||||
|
{
|
||||||
|
WCHAR chAccess = GetAddressBarAccessKey(L'D');
|
||||||
|
if (lpMsg->wParam == chAccess)
|
||||||
|
{
|
||||||
|
::PostMessageW(fEditControl, EM_SETSEL, 0, -1);
|
||||||
|
::SetFocus(fEditControl);
|
||||||
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (lpMsg->hwnd == fEditControl)
|
if (lpMsg->hwnd == fEditControl)
|
||||||
{
|
{
|
||||||
switch (lpMsg->message)
|
switch (lpMsg->message)
|
||||||
|
|
Loading…
Reference in a new issue