From 318afe2bafbe9a5b63788dafe43dc52d098a3429 Mon Sep 17 00:00:00 2001 From: Yongkang Chen Date: Tue, 22 Jul 2014 15:12:40 +0800 Subject: [PATCH 1/2] add editbox ended event --- extensions/GUI/CCEditBox/CCEditBoxImplMac.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm index 8ca0fd5d25..15b4ee4e5f 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm @@ -254,6 +254,25 @@ #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 From 6dee943352184f2332838e577ab9fe0fd9ce9eb2 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 1 Aug 2014 14:56:47 +0800 Subject: [PATCH 2/2] 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