mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6295 from samuele3hu/develop_fix
fix the bug that `EditBox` can’t response that ‘changed’,`ended` and ‘return’ event for lua
This commit is contained in:
commit
3b708f4e82
|
@ -264,12 +264,12 @@ static void editBoxCallbackFunc(const char* pText, void* ctx)
|
|||
CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"ended",64);
|
||||
memset(data.eventName, 0, sizeof(data.eventName));
|
||||
strncpy(data.eventName, "ended", sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"return",64);
|
||||
memset(data.eventName, 0, sizeof(data.eventName));
|
||||
strncpy(data.eventName, "return", sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
|
|
|
@ -196,8 +196,8 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
|||
cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox);
|
||||
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
|
||||
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"return",64);
|
||||
memset(data.eventName, 0, sizeof(data.eventName));
|
||||
strncpy(data.eventName, "return", sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
|
|
|
@ -187,8 +187,8 @@
|
|||
cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox);
|
||||
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
|
||||
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"return",64);
|
||||
memset(data.eventName, 0, sizeof(data.eventName));
|
||||
strncpy(data.eventName, "return", sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
|
|
|
@ -234,35 +234,6 @@ void EditBoxImplWin::visit(void)
|
|||
{
|
||||
}
|
||||
|
||||
static void editBoxCallbackFunc(const char* pText, void* ctx)
|
||||
{
|
||||
EditBoxImplWin* thiz = (EditBoxImplWin*)ctx;
|
||||
thiz->setText(pText);
|
||||
|
||||
if (thiz->getDelegate() != NULL)
|
||||
{
|
||||
thiz->getDelegate()->editBoxTextChanged(thiz->getEditBox(), thiz->getText());
|
||||
thiz->getDelegate()->editBoxEditingDidEnd(thiz->getEditBox());
|
||||
thiz->getDelegate()->editBoxReturn(thiz->getEditBox());
|
||||
}
|
||||
|
||||
EditBox* pEditBox = thiz->getEditBox();
|
||||
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
|
||||
{
|
||||
CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"ended",64);
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"return",64);
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
void EditBoxImplWin::openKeyboard()
|
||||
{
|
||||
if (_delegate != NULL)
|
||||
|
@ -300,6 +271,26 @@ void EditBoxImplWin::openKeyboard()
|
|||
_delegate->editBoxEditingDidEnd(_editBox);
|
||||
_delegate->editBoxReturn(_editBox);
|
||||
}
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler())
|
||||
{
|
||||
CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed",_editBox);
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
if (didChange)
|
||||
{
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
memset(data.eventName,0,sizeof(data.eventName));
|
||||
strncpy(data.eventName,"ended",sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,sizeof(data.eventName));
|
||||
strncpy(data.eventName,"return",sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
#endif // #if CC_ENABLE_SCRIPT_BINDING
|
||||
}
|
||||
|
||||
void EditBoxImplWin::closeKeyboard()
|
||||
|
|
Loading…
Reference in New Issue