cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.25k stars 7.06k forks source link

UIEditbox setMaxLength is invalid in mac #8562

Closed vvhh2002 closed 10 years ago

vvhh2002 commented 10 years ago

the UIEditBox-Impl-mac.mm should change like this:

/**

cocos2d::extension::EditBox*  pEditBox= getEditBoxImplMac()->getEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
    cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
    cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
    cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}

endif

}

minggo commented 10 years ago

@andyque Could you please take a look?

zilongshanren commented 10 years ago

@vvhh2002 Thanks, your fix works but I think it's not the perfect way to restrict max length of NSTextField. Here is a link explains why: http://stackoverflow.com/questions/827014/how-to-limit-nstextfield-text-length-and-keep-it-always-upper-case

I will try to fix this issue by applying the method proposed in stackoverflow.