{"action":"opened","issue":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/14013","labels_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/14013/labels{/name}","comments_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/14013/comments","events_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/14013/events","html_url":"https://github.com/cocos2d/cocos2d-x/issues/14013","id":108274019,"number":14013,"title":"BUG：Layout裁剪","user":{"login":"1078559858","id":7157980,"avatar_url":"https://avatars.githubusercontent.com/u/7157980?v=3","gravatar_id":"","url":"https://api.github.com/users/1078559858","html_url":"https://github.com/1078559858","followers_url":"https://api.github.com/users/1078559858/followers","following_url":"https://api.github.com/users/1078559858/following{/other_user}","gists_url":"https://api.github.com/users/1078559858/gists{/gist_id}","starred_url":"https://api.github.com/users/1078559858/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1078559858/subscriptions","organizations_url":"https://api.github.com/users/1078559858/orgs","repos_url":"https://api.github.com/users/1078559858/repos","events_url":"https://api.github.com/users/1078559858/events{/privacy}","received_events_url":"https://api.github.com/users/1078559858/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-25T06:53:51Z","updated_at":"2015-09-25T06:53:51Z","closed_at":null,"body":"环境：3.8\r\n描述：\r\n创建Layout\r\n{\r\n\t创建Layout1\r\n\t{\r\n\t\tLayout1->setClippingEnabled(true);//面板1开启裁切\r\n\t\t创建Layout2\r\n\t\t{\r\n\t\t\t创建Layout2->setClippingEnabled（true）;//面板2开启裁切\t\r\n\t\t\t创建Btn\r\n\t\t\tBtn->setTouchEnabled(true);\t\r\n\t\t\t}\r\n\t}\r\n}\r\n\r\n当一个面板含有这种结构的时候，点击里面的按钮响应消息就需要点击两次\r\n问题分析：\r\nbool Widget::isClippingParentContainsPoint(const Vec2 &pt)函数中的\r\nif (layoutParent->isClippingEnabled())\r\n            {\r\n                _affectByClipping = true;\r\n                clippingParent = layoutParent;\r\n                break;\r\n            }\r\n和\r\n if (clippingParent)\r\n    {\r\n        bool bRet = false;\r\n        if (clippingParent->hitTest(pt, _hittedByCamera, nullptr))\r\n        {\r\n            bRet = true;\r\n        }\r\n        if (bRet)\r\n        {\r\n            return clippingParent->isClippingParentContainsPoint(pt);\r\n        }\r\n        return false;\r\n    }\r\n递归出错，导致第二次遍历_hittedByCamera为null。\r\n\r\n解决办法：\r\n      bool bRet = false;\r\n\t\tauto carmera = Camera::getVisitingCamera();\r\n\t\tif (clippingParent->hitTest(pt, carmera, nullptr))\r\n\r\n（ps：这是网友提供，我负责上传到git上。）\r\n\r\n\r\n"}}