void PropertyTree::OnKeyDown(UINT nChar, UINT, UINT) { PropertyTreeItem* pItem; switch (nChar) { case VK_RETURN: if ((pItem = GetFocusedItem())!=NULL && !pItem->IsRootLevel()) { pItem->Activate(); } break; case VK_LEFT: if ((pItem = GetFocusedItem())!=NULL) { if (!SendNotify(PTN_ITEMEXPANDING, pItem)) { if (pItem->GetChild() && pItem->IsExpanded()) { pItem->Expand(FALSE); UpdateScrollbar(); Invalidate(); UpdateWindow(); CheckVisibleFocus(); break; } } } else break; // pass thru to next case VK_UP case VK_UP: if (FocusPrev()) Invalidate(); break; case VK_RIGHT: if ((pItem = GetFocusedItem())!=NULL) { if (!SendNotify(PTN_ITEMEXPANDING, pItem)) { if (pItem->GetChild() && !pItem->IsExpanded()) { pItem->Expand(); UpdateScrollbar(); Invalidate(); UpdateWindow(); CheckVisibleFocus(); break; } } } else break; // pass thru to next case VK_DOWN case VK_DOWN: if (FocusNext()) Invalidate(); break; } }
int CMenu::Run() { if ( m_oItems[m_iCurrentItem]->GetEnabled() ) { m_oItems[m_iCurrentItem]->SetActive(true); } else { FocusNext(); } Draw(); while ( !m_bDone ) { if ( g_oState.m_bQuitFlag ) { m_bDone = true; m_iReturnCode = -1; break; } SDLKey enKey = GetKey( true ); if ( g_oState.m_bQuitFlag || SDLK_ESCAPE == enKey ) { m_bDone = true; m_iReturnCode = -1; break; } switch ( enKey ) { case SDLK_UP: { FocusPrev(); break; } // end of SDLK_UP case SDLK_DOWN: { FocusNext(); break; } // end of SDLK_DOWN case SDLK_LEFT: { CMenuItem* poItem = m_oItems[m_iCurrentItem]; poItem->Decrement(); break; } case SDLK_RIGHT: { CMenuItem* poItem = m_oItems[m_iCurrentItem]; poItem->Increment(); break; } case SDLK_RETURN: { CMenuItem* poItem = m_oItems[m_iCurrentItem]; if ( poItem->GetEnabled() ) { poItem->Activate(); } } default: break; } // end of switch } Clear(); return m_iReturnCode; }