diff --git a/base/applications/rapps/gui.cpp b/base/applications/rapps/gui.cpp index ad2a13f9a9f..182d1068665 100644 --- a/base/applications/rapps/gui.cpp +++ b/base/applications/rapps/gui.cpp @@ -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); }