Cocos2dxEditBox.java,目前3,8.1可以修改这个java源文件就可以修改到包括EditBox,TextFiled,UITextFiled的返回键按两次才能切回到原来的焦点上,
之前在onKeyDown上修改
@Override
public boolean onKeyDown(final int pKeyCode,final KeyEvent pKeyEvent) {
switch (pKeyCode) {
case KeyEvent.KEYCODE_BACK:
Cocos2dxActivity activity = (Cocos2dxActivity)this.getContext();
//To prevent program from going to background
activity.getGLSurfaceView().requestFocus();
return true;
default:
return super.onKeyDown(pKeyCode,pKeyEvent);
}
}
后来才将
@Override
publicbooleanonKeyPreIme(intkeyCode,KeyEvent event) {
returnsuper.onKeyPreIme(keyCode,event);
}
改为@Override
public boolean onKeyPreIme(int keyCode,KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK)
{//此处代码是为了解决back返回键需要两次的问题 oyzm
Cocos2dxActivity activity = (Cocos2dxActivity)this.getContext();
//To prevent program from going to background
activity.getGLSurfaceView().requestFocus();
System.out.println("onKeyPreIme:::" + keyCode);
return false;
}
return super.onKeyPreIme(keyCode,event);
}