void CBuddycloudListComponent::HandlePointerEventL(const TPointerEvent &aPointerEvent) { CCoeControl::HandlePointerEventL(aPointerEvent); if(aPointerEvent.iType == TPointerEvent::EButton1Up) { if(iDraggingAllowed) { if(Abs(iDragVelocity) > 5.0) { TimerExpired(KDragTimerId); } } else { for(TInt i = 0; i < iListItems.Count(); i++) { if(iListItems[i].iRect.Contains(aPointerEvent.iPosition)) { // Provide feedback iTouchFeedback->InstantFeedback(ETouchFeedbackBasic); HandleItemSelection(iListItems[i].iId); break; } } } } else if(aPointerEvent.iType == TPointerEvent::EButton1Down) { iDragTimer->Stop(); iDragVelocity = 0.0; iDraggingAllowed = false; iStartDragPosition = aPointerEvent.iPosition.iY; iStartDragHandlePosition = iScrollbarHandlePosition; iLastDragTime.UniversalTime(); iLastDragPosition = iStartDragPosition; } else if(aPointerEvent.iType == TPointerEvent::EDrag) { if(!iDraggingAllowed && (aPointerEvent.iPosition.iY + 32 < iStartDragPosition || aPointerEvent.iPosition.iY - 32 > iStartDragPosition)) { iDraggingAllowed = true; iSnapToItem = false; } if(iDraggingAllowed) { TTime aNow; aNow.UniversalTime(); iDragVelocity = TReal(TReal(iLastDragPosition - aPointerEvent.iPosition.iY) * (1000000.0 / TReal(aNow.MicroSecondsFrom(iLastDragTime).Int64()))) / 20.0; iLastDragTime.UniversalTime(); iLastDragPosition = aPointerEvent.iPosition.iY; iScrollbarHandlePosition = iStartDragHandlePosition + (iStartDragPosition - aPointerEvent.iPosition.iY); CBuddycloudListComponent::RepositionItems(false); RenderScreen(); } } }
bool InventoryView::RequestInput() { int ch = getch(); Player* p = DataManager::Instance()->GetPlayer(); Inventory& inv = p->GetInventory(); switch(ch) { case KEY_UP: if(m_inInventoryArea && inv.NumItems() == 0) { break; } m_selectIdx--; if(m_selectIdx < 0) { m_selectIdx = 0; } break; case KEY_DOWN: if(m_inInventoryArea && inv.NumItems() == 0) { break; } m_selectIdx++; if(m_inInventoryArea) { if(m_selectIdx >= inv.NumItems()) { m_selectIdx = inv.NumItems() - 1; } } else { if(m_selectIdx > 4) { m_selectIdx = 4; } } break; case 'd': if(m_inInventoryArea && m_selectIdx < inv.NumItems()) { inv.RemoveItemAtIndex(m_selectIdx); m_selectIdx = 0; m_scrollY = 0; } break; case KEY_LEFT: m_inInventoryArea = !m_inInventoryArea; m_selectIdx = 0; break; case KEY_RIGHT: m_inInventoryArea = !m_inInventoryArea; m_selectIdx = 0; break; case '\n': case KEY_ENTER: HandleItemSelection(); break; case 27: m_parent->ChangeState(GAME_STATE_MAIN); break; } if(m_inInventoryArea && !IsIndexOnScreen(m_selectIdx)) { if(m_selectIdx < m_scrollY) { m_scrollY = m_selectIdx; } else { m_scrollY = m_selectIdx - 18; if(m_scrollY < 0) { m_scrollY = 0; } } } return false; }