fix mac EditBox callback issue

This commit is contained in:
andyque 2014-08-01 14:56:47 +08:00
parent 630c41e4a3
commit 6dee943352
1 changed files with 2 additions and 23 deletions

View File

@ -162,7 +162,7 @@
{ {
} }
- (BOOL)textFieldShouldBeginEditing:(NSTextField *)sender // return NO to disallow editing. - (void)controlTextDidBeginEditing:(NSNotification *)notification
{ {
editState_ = YES; editState_ = YES;
cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate();
@ -180,10 +180,9 @@
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
} }
#endif #endif
return YES;
} }
- (BOOL)textFieldShouldEndEditing:(NSTextField *)sender - (void)controlTextDidEndEditing:(NSNotification *)notification
{ {
editState_ = NO; editState_ = NO;
cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate();
@ -206,7 +205,6 @@
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
} }
#endif #endif
return YES;
} }
/** /**
@ -254,25 +252,6 @@
#endif #endif
} }
- (void)controlTextDidEndEditing:(NSNotification *)notification
{
if ( [[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] != NSReturnTextMovement )
{
return;
}
#if CC_ENABLE_SCRIPT_BINDING
cocos2d::extension::EditBox* pEditBox= getEditBoxImplMac()->getEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox);
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
#endif
}
@end @end
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN