Skip to content

Commit dee7718

Browse files
committed
[RAPPS] Allow tabbing trough controls in the main window
1 parent 2eed38e commit dee7718

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

base/applications/rapps/gui.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,29 @@ class CMainWindow :
18501850

18511851
return CWindowImpl::Create(NULL, r, szWindowName.GetString(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
18521852
}
1853+
1854+
void HandleTabOrder(int direction)
1855+
{
1856+
HWND Controls[] = { m_Toolbar->m_hWnd, m_SearchBar->m_hWnd, m_TreeView->m_hWnd, m_ListView->m_hWnd, m_RichEdit->m_hWnd };
1857+
// When there is no control found, go to the first or last (depending on tab vs shift-tab)
1858+
int current = direction > 0 ? 0 : (_countof(Controls) - 1);
1859+
HWND hActive = ::GetFocus();
1860+
for (int n = 0; n < _countof(Controls); ++n)
1861+
{
1862+
if (hActive == Controls[n])
1863+
{
1864+
current = n + direction;
1865+
break;
1866+
}
1867+
}
1868+
1869+
if (current < 0)
1870+
current = (_countof(Controls) - 1);
1871+
else if (current >= _countof(Controls))
1872+
current = 0;
1873+
1874+
::SetFocus(Controls[current]);
1875+
}
18531876
};
18541877

18551878
VOID ShowMainWindow(INT nShowCmd)
@@ -1877,6 +1900,16 @@ VOID ShowMainWindow(INT nShowCmd)
18771900
{
18781901
if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
18791902
{
1903+
if (Msg.message == WM_CHAR &&
1904+
Msg.wParam == VK_TAB)
1905+
{
1906+
// Move backwards if shift is held down
1907+
int direction = (GetKeyState(VK_SHIFT) & 0x8000) ? -1 : 1;
1908+
1909+
wnd->HandleTabOrder(direction);
1910+
continue;
1911+
}
1912+
18801913
TranslateMessage(&Msg);
18811914
DispatchMessageW(&Msg);
18821915
}

0 commit comments

Comments
 (0)