我们将一列button添加到scrollview中,并且给scrollview设定好剪切区域。
然后在剪切区域外的button依旧会拦截并响应点击事件,这个问题有办法解决么?
感谢 http://www.cocoachina.com/bbs/u.php?action=feed&uid=253888 的提醒,我把解决方案写一下吧。其实很简单,就修改两行代码,把getWidgetParent 改成 getParent
找到cocos2dx中负责剪切判断的函数:
bool Widget::isClippingParentContainsPoint(const Vec2 &pt)
{
_affectByClipping = false;
// FIXME
#if 0
Widget* parent = getWidgetParent();
Widget* clippingParent = nullptr;
while (parent)
{
Layout* layoutParent = dynamic_cast<Layout*>(parent);
if (layoutParent)
{
if (layoutParent->isClippingEnabled())
{
_affectByClipping = true;
clippingParent = layoutParent;
break;
}
}
parent = parent->getWidgetParent();
}
#else
Node* parent = getParent();
Widget* clippingParent = nullptr;
while (parent)
{
Layout* layoutParent = dynamic_cast<Layout*>(parent);
if (layoutParent)
{
if (layoutParent->isClippingEnabled())
{
_affectByClipping = true;
clippingParent = layoutParent;
break;
}
}
parent = parent->getParent();
}
#endif
