Fix widget onEnter override in JS may cause infinite recursion

This commit is contained in:
pandamicro 2015-07-28 16:04:28 +08:00
parent 3a58668d71
commit 0a31199a5b
1 changed files with 16 additions and 0 deletions

View File

@ -223,6 +223,14 @@ bool Widget::init()
void Widget::onEnter()
{
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter))
return;
}
#endif
if (!_usingLayoutComponent)
updateSizeAndPosition();
ProtectedNode::onEnter();
@ -230,6 +238,14 @@ void Widget::onEnter()
void Widget::onExit()
{
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
if (ScriptEngineManager::sendNodeEventToJS(this, kNodeOnExit))
return;
}
#endif
unscheduleUpdate();
ProtectedNode::onExit();
}