cocos2dx edit编辑框点击后显示一个键盘,但是非常的不灵活,点return才能隐藏,如果我们需要点键盘外的背景,实现隐藏键盘,那就方便多了
方法:
1. 到EGLView.mm下 注释2个reurn,这样就能保证显示软键盘的时候,还能将点击事件传送到最底层
- //Passthetouchestothesuperview
- #pragmamarkEAGLView-TouchDelegate
- -(@H_404_47@void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event
- {
- if(isKeyboardShown_)
- [selfhandletouchesAfterKeyboardShow];
- //WARNING:commentedbyTeng.点触背景隐藏软键盘
- //return;
- }
- intids[IOS_MAX_touches_COUNT]={0};
- floatxs[IOS_MAX_touches_COUNT]={0.0f};
- floatys[IOS_MAX_touches_COUNT]={0.0f};
- inti=0;
- for(UITouch*touchintouches){
- ids[i]=(int)touch;
- xs[i]=[touchlocationInView:[touchview]].x*view.contentScaleFactor;;
- ys[i]=[touchlocationInView:[touchview]].y*view.contentScaleFactor;;
- ++i;
- cocos2d::CCEGLView::sharedOpenGLView()->handletouchesBegin(i,ids,xs,ys);
- }
copy