https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3ac5de4102cef3c7acb3579049115aae43ddd7a2

commit 3ac5de4102cef3c7acb3579049115aae43ddd7a2
Author:     Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com>
AuthorDate: Wed Jan 24 17:52:36 2024 +0900
Commit:     GitHub <nore...@github.com>
CommitDate: Wed Jan 24 17:52:36 2024 +0900

    [SDK] cicuif.h: Fix CUIFMenu::OnKeyDown (#6408)
    
    Supporting Language Bar...
    JIRA issue: CORE-19363
    Implement CUIFMenu::OnKeyDown
    method.
---
 sdk/include/reactos/cicero/cicuif.h | 78 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 76 insertions(+), 2 deletions(-)

diff --git a/sdk/include/reactos/cicero/cicuif.h 
b/sdk/include/reactos/cicero/cicuif.h
index f6fcf6a9f0c..77e84fff690 100644
--- a/sdk/include/reactos/cicero/cicuif.h
+++ b/sdk/include/reactos/cicero/cicuif.h
@@ -5771,11 +5771,85 @@ CUIFMenu::ModalMouseNotify(UINT uMsg, LONG x, LONG y)
         CancelMenu();
 }
 
-/// @unimplemented
 inline STDMETHODIMP_(void)
 CUIFMenu::OnKeyDown(HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
-    //FIXME
+    CUIFMenuItem *pTargetItem;
+
+    BYTE vKey = (BYTE)wParam;
+
+    switch (vKey)
+    {
+        case VK_ESCAPE:
+            CancelMenu();
+            return;
+
+        case VK_LEFT:
+            if (!m_pVisibleSubMenu)
+                return;
+
+            CancelMenu();
+            return;
+
+        case VK_RIGHT:
+            if (m_pSelectedItem && m_pSelectedItem->m_pSubMenu)
+            {
+                m_pSelectedItem->ShowSubPopup();
+                CUIFMenu *pSubMenu = m_pSelectedItem->m_pSubMenu;
+                pTargetItem = pSubMenu->GetNextItem(NULL);
+                pSubMenu->SetSelectedItem(pTargetItem);
+            }
+            return;
+
+        case VK_UP:
+            pTargetItem = GetPrevItem(m_pSelectedItem);
+            SetSelectedItem(pTargetItem);
+            return;
+
+        case VK_DOWN:
+            pTargetItem = GetNextItem(m_pSelectedItem);
+            SetSelectedItem(pTargetItem);
+            return;
+
+        case VK_RETURN:
+            break;
+
+        default:
+        {
+            if (!(('A' <= vKey && vKey <= 'Z') || ('0' <= vKey && vKey <= 
'9')))
+                return;
+
+            size_t iItem;
+            for (iItem = 0; iItem < m_MenuItems.size(); ++iItem)
+            {
+                CUIFMenuItem *pItem = m_MenuItems[iItem];
+                if (pItem->m_nMenuItemVKey == vKey)
+                {
+                    SetSelectedItem(pItem);
+                    break;
+                }
+            }
+
+            if (iItem == m_MenuItems.size())
+                return;
+        }
+    }
+
+    if (m_pSelectedItem && !m_pSelectedItem->m_bMenuItemGrayed)
+    {
+        CUIFMenu *pSubMenu = m_pSelectedItem->m_pSubMenu;
+        if (pSubMenu)
+        {
+            m_pSelectedItem->ShowSubPopup();
+            pTargetItem = pSubMenu->GetNextItem(NULL);
+            pSubMenu->SetSelectedItem(pTargetItem);
+        }
+        else
+        {
+            SetSelectedId(m_pSelectedItem->m_nMenuItemID);
+            ::PostMessage(m_hWnd, WM_NULL, 0, 0);
+        }
+    }
 }
 
 inline void CUIFMenu::PostKey(BOOL bUp, WPARAM wParam, LPARAM lParam)

Reply via email to