fix ScrollView bug

I Fixed a bug that scroll view hidden picks up the touch events.
This commit is contained in:
DENPEN 2014-09-05 20:49:15 +09:00
parent 78d4e9797c
commit 0cfb8c6469
2 changed files with 16 additions and 1 deletions

View File

@ -343,6 +343,19 @@ void ScrollView::setContainer(Node * pContainer)
this->setViewSize(this->_viewSize);
}
bool ScrollView::hasVisibleParents() const
{
auto parent = this->getParent();
for( auto c = parent; c != nullptr; c = c->getParent() )
{
if( !c->isVisible() )
{
return false;
}
}
return true;
}
void ScrollView::relocateContainer(bool animated)
{
Vec2 oldPoint, min, max;
@ -625,7 +638,7 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t
bool ScrollView::onTouchBegan(Touch* touch, Event* event)
{
if (!this->isVisible())
if (!this->isVisible() || !this->hasVisibleParents())
{
return false;
}

View File

@ -256,6 +256,8 @@ public:
* CCActionTweenDelegate
*/
void updateTweenAction(float value, const std::string& key);
bool hasVisibleParents() const;
protected:
/**
* Relocates the container at the proper offset, in bounds of max/min offsets.