Skip to content

Commit a4e8c3d

Browse files
happyzhaolejianglong-zz
authored andcommitted
fix the layer touch recover, using the Scene:
add layer XX into the scene. and setTouchEnabled false, then, remove XX from the scene,but not release. at last , add XX into scene again, it will setTouchEnable true. So, this is a bug, the layer add into scene again, the touch state need to same with it onExit
1 parent 0a49ebe commit a4e8c3d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

extensions/CocoStudio/GUI/System/UITouchGroup.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ NS_CC_BEGIN
3030
namespace ui {
3131

3232
TouchGroup::TouchGroup():
33-
m_pRootWidget(NULL)
33+
m_pRootWidget(NULL),
34+
m_bTouchEnabledExit(true)
3435
{
3536
}
3637

@@ -50,6 +51,7 @@ bool TouchGroup::init()
5051
m_pRootWidget = Widget::create();
5152
m_pRootWidget->retain();
5253
addChild(m_pRootWidget);
54+
setTouchEnabled(true);
5355
return true;
5456
}
5557
return false;
@@ -73,16 +75,25 @@ TouchGroup* TouchGroup::create(void)
7375
void TouchGroup::onEnter()
7476
{
7577
setTouchMode(kCCTouchesOneByOne);
76-
setTouchEnabled(true);
78+
bool isTouchGroupTouch = this->m_bTouchEnabledExit;
79+
setTouchEnabled(isTouchGroupTouch);
7780
CCLayer::onEnter();
7881
}
7982

8083
void TouchGroup::onExit()
8184
{
85+
bool isTouchGroupTouch = isTouchEnabled();
8286
setTouchEnabled(false);
87+
this->m_bTouchEnabledExit = isTouchGroupTouch;
8388
CCLayer::onExit();
8489
}
8590

91+
void TouchGroup::setTouchEnabled(bool enabled)
92+
{
93+
this->m_bTouchEnabledExit = enabled;
94+
CCLayer::setTouchEnabled(enabled);
95+
}
96+
8697
void TouchGroup::onEnterTransitionDidFinish()
8798
{
8899
CCLayer::onEnterTransitionDidFinish();

extensions/CocoStudio/GUI/System/UITouchGroup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ class CC_EX_DLL TouchGroup : public CCLayer
114114
protected:
115115
bool checkEventWidget(CCTouch* touch, CCEvent *pEvent);
116116
bool checkTouchEvent(Widget* root, CCTouch* touch, CCEvent* pEvent);
117+
void setTouchEnabled(bool enabled);
117118
protected:
118119
Widget* m_pRootWidget;
119120
CCPoint touchBeganedPoint;
120121
CCPoint touchMovedPoint;
121122
CCPoint touchEndedPoint;
122123
CCPoint touchCanceledPoint;
123124
CCArray* m_pSelectedWidgets;
125+
bool m_bTouchEnabledExit;
124126
};
125127

126128
}

0 commit comments

Comments
 (0)