void CRegionViewCommand::SetToggle(DWORD dwIndex, const CUIEvent &cEvent) { if (GetToggleCount() <= dwIndex) SetToggleCount(dwIndex + 1); delete m_cToggleList[dwIndex]; m_cToggleList[dwIndex] = cEvent.Clone(); }
//adds a key to the list of keys needed to trigger the event //returns true if it successful, or false if there is //no more room to store the key bool CHotKey::AddEvent(const CUIEvent& Event) { //clone it and add it to the starting list CUIEvent* pClone = Event.Clone(); //ensure it worked properly if(pClone == LTNULL) { return false; } //add it to the starting list m_StartEventList.Add(pClone); //find the inverse int nInverse = UIEVENT_NONE; switch(pClone->GetType()) { case UIEVENT_KEYDOWN: nInverse = UIEVENT_KEYUP; break; case UIEVENT_KEYUP: nInverse = UIEVENT_KEYDOWN; break; case UIEVENT_MOUSEDOWN: nInverse = UIEVENT_MOUSEUP; break; case UIEVENT_MOUSEUP: nInverse = UIEVENT_MOUSEDOWN; break; default: nInverse = UIEVENT_NONE; break; } //if it was a valid inverse, lets add it to the end list if(nInverse != UIEVENT_NONE) { //add another clone pClone = Event.Clone(); if(pClone) { //but switch this one to the inverse pClone->SetType(nInverse); m_EndEventList.Add(pClone); } } return true; }