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); }
LuaEventHandler * CCBProxy::getHandler(const int handler){ CCObject *o; LuaEventHandler *h; CCARRAY_FOREACH(_handlers, o){ h = (LuaEventHandler *)o; if(h->getHandler() == handler){ return h; } }
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; }
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); }
virtual void scrollViewDidZoom(CCScrollView *s){ CCTableView::scrollViewDidZoom(s); _handler->scrollViewDidZoom(this); }
virtual void scrollViewDidScroll(CCScrollView *s){ CCTableView::scrollViewDidScroll(s); _handler->scrollViewDidScroll(this); updateScroll(); }
LuaEventHandler * LuaEventHandler::create(lua_State *l){ LuaEventHandler *h = new LuaEventHandler(); h->_lua = l == NULL? luaStateForEngine() : l; h->autorelease(); return h; }