diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index e97d2672be..68181bd899 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -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; } diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index 72695df5c7..36f94d39f8 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -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.