EditBox return key only hides the virtual keyboard, and can not write the input content to the game, nothing can be done, the experience is bad.
Cocos2d-x run apk on Android phone , there is a bunch of Java files (\runtime-src\proj.android\src\org\cocos2dx\lib)
1.
Locate cocos2dxeditboxdialog.java file
2. Import event mechanism
Import Android.view.View.OnClickListener; --After copying to 44 rows.
3. Implement Onclicklistener Interface
public class Cocos2dxeditboxdialog extends Dialog implements Onclicklistener{--line 56th
4. Registering events for the default layout
Layout.setonclicklistener (this); --Add to 158 lines
5. At this point, there should be a rewrite of the OnClick method
@Override
public void onClick (View v) {
// TODO auto-generated method stub
log.d ("shixc==============", "OnClick");
Cocos2dxhelper.setedittextdialogresult (cocos2dxeditboxdialog. This. Minputedittext. GetText (). toString ());
Cocos2dxeditboxdialog. This . Closekeyboard ();
Cocos2dxeditboxdialog. This . Dismiss ();
}
6, now Android simulation when we can click the blank exit Edit. But then register the listener event with the return key
Add the following code around 290 lines
public boolean dispatchkeyevent (keyevent event) {
System. out. println ("shixclog================" + event.getaction () + event. getKeyCode () + KeyEvent. keycode_back);
if (event. getKeyCode () = = KeyEvent. Keycode_back) {
Cocos2dxhelper.setedittextdialogresult (cocos2dxeditboxdialog. This. Minputedittext. GetText (). toString ());
Cocos2dxeditboxdialog. This. Closekeyboard ();
Cocos2dxeditboxdialog. This. Dismiss ();
return true;
}
return Super. Dispatchkeyevent (event); //
}
EditBox register return key and click Blank return time input content cannot be written to the game