From 6dee943352184f2332838e577ab9fe0fd9ce9eb2 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 1 Aug 2014 14:56:47 +0800 Subject: [PATCH] fix mac EditBox callback issue --- extensions/GUI/CCEditBox/CCEditBoxImplMac.mm | 25 ++------------------ 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm index 7c471bc465..1d716fa700 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm @@ -162,7 +162,7 @@ { } -- (BOOL)textFieldShouldBeginEditing:(NSTextField *)sender // return NO to disallow editing. +- (void)controlTextDidBeginEditing:(NSNotification *)notification { editState_ = YES; cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); @@ -180,10 +180,9 @@ cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } #endif - return YES; } -- (BOOL)textFieldShouldEndEditing:(NSTextField *)sender +- (void)controlTextDidEndEditing:(NSNotification *)notification { editState_ = NO; cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); @@ -206,7 +205,6 @@ cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } #endif - return YES; } /** @@ -254,25 +252,6 @@ #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 NS_CC_EXT_BEGIN