实现带光标的输入框。有需要的可以使用。

CCEditBox,在android上用户体验太差了,自己做程序的觉得那样输入还可以,不过程序上线以后,好多用户反应,注册的时候,输入完以后就没发操作了,因为在android上用户必须点击右下脚的回车在能收回键盘,后来用CCTextFieldTTF,却发现没右光标,体验还是不好,
现在只是增加了光标以及点击空白区域收回键盘。以及增加了键盘出现消失的通知。
android上现在接受不到通知,暂时不知道怎么搞,希望各位朋友帮着完善下。

.android 上需要修改,cocos2dx 的
EAGLView
增加方法existNeedHiddenkeyboardShow

-(BOOL)existNeedHiddenkeyboardShow
{
NSArray *subviews = self.subviews;

for(UIView* view in subviews)
{

if(isKindOfClass:NSClassFromString(@“CustomUITextField”)])
{
if (isFirstResponder])
{
resignFirstResponder];
return true;
}
}
}
return false;
}

修改touchesBegan

  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
    if (isKeyboardShown_)
    {
    BOOL existKeyBoard=self existNeedHiddenkeyboardShow];
    if (existKeyBoard) {
    return;
    }

    }

修改touchesend

  • (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {
    if (isKeyboardShown_)
    {
    //return;
    }

哎呦,太巧了,我正打算做这个功能呢。下下来瞅瞅:14:

我试了下,点击空白区域并没有收回键盘呀~我用2.2.1测的ios

EAGLView 修改

是改称你在上面贴的代码吗?还是不会收回呀,而且你的 existNeedHiddenkeyboardShow 函数和 handleTouchesAfterKeyboardShow 是一样的

我找到了这两篇文章
http://blog.csdn.net/onerain88/article/details/7572315
http://socol.iteye.com/blog/1843259

正式我需要的。谢谢分享。

谢谢楼主的奉献精神:874: