mirror of https://github.com/axmolengine/axmol.git
Fixed #5563: Add sendNodeEventToJSExtended function to fix issues and remove lua event send (unnecessary)
This commit is contained in:
parent
d524ba1013
commit
d00c9fe70a
|
@ -145,7 +145,7 @@ void ClippingNode::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -160,13 +160,6 @@ void ClippingNode::onEnter()
|
|||
{
|
||||
CCLOG("ClippingNode warning: _stencil is nil.");
|
||||
}
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ClippingNode::onEnterTransitionDidFinish()
|
||||
|
|
|
@ -82,6 +82,7 @@ static bool sendNodeEventToJS(Node* node, int action)
|
|||
|
||||
if (scriptEngine->isCalledFromScript())
|
||||
{
|
||||
// Should only be invoked at root class Node
|
||||
scriptEngine->setCalledFromScript(false);
|
||||
}
|
||||
else
|
||||
|
@ -94,6 +95,20 @@ static bool sendNodeEventToJS(Node* node, int action)
|
|||
|
||||
return false;
|
||||
}
|
||||
static bool sendNodeEventToJSExtended(Node* node, int action)
|
||||
{
|
||||
auto scriptEngine = ScriptEngineManager::getInstance()->getScriptEngine();
|
||||
|
||||
if (!scriptEngine->isCalledFromScript())
|
||||
{
|
||||
BasicScriptData data(node,(void*)&action);
|
||||
ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
|
||||
if (scriptEngine->sendEvent(&scriptEvent))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void sendNodeEventToLua(Node* node, int action)
|
||||
{
|
||||
|
|
|
@ -619,7 +619,7 @@ void ParticleSystem::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -628,13 +628,6 @@ void ParticleSystem::onEnter()
|
|||
|
||||
// update after action in run!
|
||||
this->scheduleUpdateWithPriority(1);
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ParticleSystem::onExit()
|
||||
|
|
|
@ -437,20 +437,13 @@ void Armature::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Node::onEnter();
|
||||
scheduleUpdate();
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Armature::onExit()
|
||||
|
|
|
@ -279,20 +279,13 @@ void Skeleton::onEnter() {
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Node::onEnter();
|
||||
scheduleUpdate();
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Skeleton::onExit() {
|
||||
|
|
|
@ -340,7 +340,7 @@ void ProtectedNode::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -348,13 +348,6 @@ void ProtectedNode::onEnter()
|
|||
Node::onEnter();
|
||||
for( const auto &child: _protectedChildren)
|
||||
child->onEnter();
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProtectedNode::onEnterTransitionDidFinish()
|
||||
|
|
|
@ -105,7 +105,7 @@ void Layout::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -117,13 +117,6 @@ void Layout::onEnter()
|
|||
}
|
||||
_doLayoutDirty = true;
|
||||
_clippingRectDirty = true;
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Layout::onExit()
|
||||
|
|
|
@ -71,20 +71,13 @@ void PageView::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Layout::onEnter();
|
||||
scheduleUpdate();
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PageView::init()
|
||||
|
|
|
@ -98,20 +98,13 @@ void ScrollView::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Layout::onEnter();
|
||||
scheduleUpdate();
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ScrollView::init()
|
||||
|
|
|
@ -418,20 +418,13 @@ void TextField::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Widget::onEnter();
|
||||
scheduleUpdate();
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void TextField::initRenderer()
|
||||
|
|
|
@ -332,7 +332,7 @@ void EditBox::onEnter(void)
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -345,13 +345,6 @@ void EditBox::onEnter(void)
|
|||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
this->schedule(schedule_selector(EditBox::updatePosition), CHECK_EDITBOX_POSITION_INTERVAL);
|
||||
#endif
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void EditBox::updatePosition(float dt)
|
||||
|
|
Loading…
Reference in New Issue