[RAPPS] Allow tabbing trough controls in the main window

This commit is contained in:
Mark Jansen 2020-02-09 17:54:18 +01:00
parent 2eed38eb5f
commit dee771817e
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B

View file

@ -1850,6 +1850,29 @@ public:
return CWindowImpl::Create(NULL, r, szWindowName.GetString(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
}
void HandleTabOrder(int direction)
{
HWND Controls[] = { m_Toolbar->m_hWnd, m_SearchBar->m_hWnd, m_TreeView->m_hWnd, m_ListView->m_hWnd, m_RichEdit->m_hWnd };
// When there is no control found, go to the first or last (depending on tab vs shift-tab)
int current = direction > 0 ? 0 : (_countof(Controls) - 1);
HWND hActive = ::GetFocus();
for (int n = 0; n < _countof(Controls); ++n)
{
if (hActive == Controls[n])
{
current = n + direction;
break;
}
}
if (current < 0)
current = (_countof(Controls) - 1);
else if (current >= _countof(Controls))
current = 0;
::SetFocus(Controls[current]);
}
};
VOID ShowMainWindow(INT nShowCmd)
@ -1877,6 +1900,16 @@ VOID ShowMainWindow(INT nShowCmd)
{
if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
{
if (Msg.message == WM_CHAR &&
Msg.wParam == VK_TAB)
{
// Move backwards if shift is held down
int direction = (GetKeyState(VK_SHIFT) & 0x8000) ? -1 : 1;
wnd->HandleTabOrder(direction);
continue;
}
TranslateMessage(&Msg);
DispatchMessageW(&Msg);
}