mirror of https://github.com/axmolengine/axmol.git
tableview touch area fix.
This commit is contained in:
parent
739048e6f2
commit
87935ac436
|
@ -332,7 +332,10 @@ unsigned int CCTableView::_indexFromOffset(CCPoint offset)
|
|||
offset.y = this->getContainer()->getContentSize().height - offset.y - cellSize.height;
|
||||
}
|
||||
index = MAX(0, this->__indexFromOffset(offset));
|
||||
index = MIN(index, maxIdx);
|
||||
if (index >maxIdx)
|
||||
{
|
||||
index = CC_INVALID_INDEX;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
@ -401,7 +404,11 @@ void CCTableView::scrollViewDidScroll(CCScrollView* view)
|
|||
offset.y = offset.y + m_tViewSize.height/this->getContainer()->getScaleY() - cellSize.height;
|
||||
}
|
||||
startIdx = this->_indexFromOffset(offset);
|
||||
|
||||
if (startIdx == CC_INVALID_INDEX)
|
||||
{
|
||||
startIdx = uCountOfItems - 1;
|
||||
}
|
||||
|
||||
if (m_eVordering == kCCTableViewFillTopDown)
|
||||
{
|
||||
offset.y -= m_tViewSize.height/this->getContainer()->getScaleY();
|
||||
|
@ -413,7 +420,11 @@ void CCTableView::scrollViewDidScroll(CCScrollView* view)
|
|||
offset.x += m_tViewSize.width/this->getContainer()->getScaleX();
|
||||
|
||||
endIdx = this->_indexFromOffset(offset);
|
||||
|
||||
if (endIdx == CC_INVALID_INDEX)
|
||||
{
|
||||
endIdx = uCountOfItems - 1;
|
||||
}
|
||||
|
||||
#if 0 // For Testing.
|
||||
CCObject* pObj;
|
||||
int i = 0;
|
||||
|
@ -492,7 +503,11 @@ void CCTableView::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
|
|||
}
|
||||
|
||||
if (m_pTouchedCell){
|
||||
if(m_pTableViewDelegate != NULL) {
|
||||
CCRect bb = this->boundingBox();
|
||||
bb.origin = m_pParent->convertToWorldSpace(bb.origin);
|
||||
|
||||
if (bb.containsPoint(pTouch->getLocation()) && m_pTableViewDelegate != NULL)
|
||||
{
|
||||
m_pTableViewDelegate->tableCellUnhighlight(this, m_pTouchedCell);
|
||||
m_pTableViewDelegate->tableCellTouched(this, m_pTouchedCell);
|
||||
}
|
||||
|
@ -523,8 +538,15 @@ bool CCTableView::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
|
|||
}
|
||||
|
||||
index = this->_indexFromOffset(point);
|
||||
m_pTouchedCell = this->cellAtIndex(index);
|
||||
|
||||
if (index == CC_INVALID_INDEX)
|
||||
{
|
||||
m_pTouchedCell = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTouchedCell = this->cellAtIndex(index);
|
||||
}
|
||||
|
||||
if (m_pTouchedCell && m_pTableViewDelegate != NULL) {
|
||||
m_pTableViewDelegate->tableCellHighlight(this, m_pTouchedCell);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ bool TableViewTestLayer::init()
|
|||
this->addChild(tableView);
|
||||
tableView->reloadData();
|
||||
|
||||
tableView = CCTableView::create(this, CCSizeMake(60, 280));
|
||||
tableView = CCTableView::create(this, CCSizeMake(60, 250));
|
||||
tableView->setDirection(kCCScrollViewDirectionVertical);
|
||||
tableView->setPosition(ccp(winSize.width-150,winSize.height/2-120));
|
||||
tableView->setDelegate(this);
|
||||
|
|
Loading…
Reference in New Issue