virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent){ if(!isVisible()){ return; } CCTableViewCell *cell = cellForTouch(pTouch); if(cell){ CCTableViewDelegate *dele = getTableViewDelegate(); LuaEventHandler *h = dynamic_cast<LuaEventHandler *>(dele); #if COCOS2D_VERSION >= 0x00030000 Array *touches = _touches; #else CCArray *touches = m_pTouches; #endif if(touches->count() == 1 && !isTouchMoved()){ if(h){ h->tableCellTouched(this, cell, pTouch);} else{ dele->tableCellTouched(this, cell);} dele->tableCellUnhighlight(this, cell); }else if(h){ h->tableCellTouchEnded(this, cell, pTouch); } }else{ printf("LuaTableView.touchEnded cell is null %f,%f\n", pTouch->getLocation().x, pTouch->getLocation().y); } CCScrollView::ccTouchEnded(pTouch, pEvent); }
bool LuaTableView::ccTouchBegan(CCTouch *t, CCEvent *e){ bool r = CCScrollView::ccTouchBegan(t, e); if(r){ CCTableViewCell *c = cellForTouch(t); LuaEventHandler *h = dynamic_cast<LuaEventHandler *>(m_pTableViewDelegate); if(c && h){ h->tableCellTouchBegan(this, c, t); } } return r; }
bool GridView::onTouchBegan(Touch *pTouch, Event *pEvent) { for (Node *c = this; c != nullptr; c = c->getParent()) { if (!c->isVisible()) { return false; } } bool touchResult = ScrollView::onTouchBegan(pTouch, pEvent); if(_touches.size() == 1) { // long index; // Vec2 point; _touchedCell = cellForTouch(pTouch); // point = this->getContainer()->convertTouchToNodeSpace(pTouch); // index = this->_indexFromOffset(point); // if (index == CC_INVALID_INDEX) // { // _touchedCell = nullptr; // } // else // { // _touchedCell = this->cellAtIndex(index); // } if (_touchedCell && _gridViewDelegate != nullptr) { // _gridViewDelegate->tableCellHighlight(this, _touchedCell); } } else if (_touchedCell) { if(_gridViewDelegate != nullptr) { // _gridViewDelegate->tableCellUnhighlight(this, _touchedCell); } _touchedCell = nullptr; } return touchResult; }
void LuaTableView::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent){ if(!isVisible()){ return; } CCTableViewCell *cell = cellForTouch(pTouch); if(cell){ LuaEventHandler *h = dynamic_cast<LuaEventHandler *>(m_pTableViewDelegate); if(m_pTouches->count() == 1 && !isTouchMoved()){ if(h){ h->tableCellTouched(this, cell, pTouch);} else{ m_pTableViewDelegate->tableCellTouched(this, cell);} }else if(h){ h->tableCellTouchEnded(this, cell, pTouch); } }else{ printf("LTV.touchEnded cell is null %f,%f\n", pTouch->getLocation().x, pTouch->getLocation().y); } CCScrollView::ccTouchEnded(pTouch, pEvent); }