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 CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -160,13 +160,6 @@ void ClippingNode::onEnter()
|
||||||
{
|
{
|
||||||
CCLOG("ClippingNode warning: _stencil is nil.");
|
CCLOG("ClippingNode warning: _stencil is nil.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClippingNode::onEnterTransitionDidFinish()
|
void ClippingNode::onEnterTransitionDidFinish()
|
||||||
|
|
|
@ -82,6 +82,7 @@ static bool sendNodeEventToJS(Node* node, int action)
|
||||||
|
|
||||||
if (scriptEngine->isCalledFromScript())
|
if (scriptEngine->isCalledFromScript())
|
||||||
{
|
{
|
||||||
|
// Should only be invoked at root class Node
|
||||||
scriptEngine->setCalledFromScript(false);
|
scriptEngine->setCalledFromScript(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -94,6 +95,20 @@ static bool sendNodeEventToJS(Node* node, int action)
|
||||||
|
|
||||||
return false;
|
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)
|
static void sendNodeEventToLua(Node* node, int action)
|
||||||
{
|
{
|
||||||
|
|
|
@ -619,7 +619,7 @@ void ParticleSystem::onEnter()
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -628,13 +628,6 @@ void ParticleSystem::onEnter()
|
||||||
|
|
||||||
// update after action in run!
|
// update after action in run!
|
||||||
this->scheduleUpdateWithPriority(1);
|
this->scheduleUpdateWithPriority(1);
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystem::onExit()
|
void ParticleSystem::onExit()
|
||||||
|
|
|
@ -437,20 +437,13 @@ void Armature::onEnter()
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Node::onEnter();
|
Node::onEnter();
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Armature::onExit()
|
void Armature::onExit()
|
||||||
|
|
|
@ -279,20 +279,13 @@ void Skeleton::onEnter() {
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Node::onEnter();
|
Node::onEnter();
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::onExit() {
|
void Skeleton::onExit() {
|
||||||
|
|
|
@ -340,7 +340,7 @@ void ProtectedNode::onEnter()
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -348,13 +348,6 @@ void ProtectedNode::onEnter()
|
||||||
Node::onEnter();
|
Node::onEnter();
|
||||||
for( const auto &child: _protectedChildren)
|
for( const auto &child: _protectedChildren)
|
||||||
child->onEnter();
|
child->onEnter();
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtectedNode::onEnterTransitionDidFinish()
|
void ProtectedNode::onEnterTransitionDidFinish()
|
||||||
|
|
|
@ -105,7 +105,7 @@ void Layout::onEnter()
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -117,13 +117,6 @@ void Layout::onEnter()
|
||||||
}
|
}
|
||||||
_doLayoutDirty = true;
|
_doLayoutDirty = true;
|
||||||
_clippingRectDirty = true;
|
_clippingRectDirty = true;
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::onExit()
|
void Layout::onExit()
|
||||||
|
|
|
@ -71,20 +71,13 @@ void PageView::onEnter()
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Layout::onEnter();
|
Layout::onEnter();
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PageView::init()
|
bool PageView::init()
|
||||||
|
|
|
@ -98,20 +98,13 @@ void ScrollView::onEnter()
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Layout::onEnter();
|
Layout::onEnter();
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScrollView::init()
|
bool ScrollView::init()
|
||||||
|
|
|
@ -418,20 +418,13 @@ void TextField::onEnter()
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Widget::onEnter();
|
Widget::onEnter();
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::initRenderer()
|
void TextField::initRenderer()
|
||||||
|
|
|
@ -332,7 +332,7 @@ void EditBox::onEnter(void)
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
if (_scriptType == kScriptTypeJavascript)
|
if (_scriptType == kScriptTypeJavascript)
|
||||||
{
|
{
|
||||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
if (sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -345,13 +345,6 @@ void EditBox::onEnter(void)
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||||
this->schedule(schedule_selector(EditBox::updatePosition), CHECK_EDITBOX_POSITION_INTERVAL);
|
this->schedule(schedule_selector(EditBox::updatePosition), CHECK_EDITBOX_POSITION_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
|
||||||
if (_scriptType == kScriptTypeLua)
|
|
||||||
{
|
|
||||||
sendNodeEventToLua(this, kNodeOnEnter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditBox::updatePosition(float dt)
|
void EditBox::updatePosition(float dt)
|
||||||
|
|
Loading…
Reference in New Issue