CCEditBox "undo/back" key bug on Android (cocos2dx 2.2.2)

CCEditBox "undo/back" key bug on Android (cocos2dx 2.2.2)
0.0 0


I am trying to use CCEditBox in Android. I have a setup where the background becomes blurred when edit box starts editing. But my problem is that if user just presses Android’s “undo/back” key while editing, the keyboard hides and app stucks there with the blurred bg since I have not been able to detect if keyboard is hidden and no callback is triggered when this undo button is used. At least not as they are triggered in iOS. Any suggestions? (Using cocos2dx 2.2.2)

Thanks in advance.


Well, I will post my own solution in case somebody hits the exact same wall I did. Maybe this is a dirty fix but this worked for me.
I had to edit file located in cocos2dx/platform/android/java/src/org/cocos2dx/lib folder

There is a line which says:

this.mInputEditText = new EditText(this.getContext());

1. I’ve replaced it with (to override onKeyPreIme):

this.mInputEditText = new EditText(this.getContext()) {
    public boolean onKeyPreIme(int keyCode, KeyEvent event)
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK)
            return true;
        return super.onKeyPreIme(keyCode, event);

2. I had to add an extra private variable which I named mOldText which will store whatever was written in my EditBox at the moment I started editing it.
3. Added the following line of code inside the Override of the run() method (right after initHandler was created):

Cocos2dxEditBoxDialog.this.mOldText = Cocos2dxEditBoxDialog.this.mInputEditText.getText().toString();

And you are done! I hope this helps someone, it works fine for me!
(I am not an expert coding for Android, in fact this is my first week, so if I did something wrong, I am sorry and please correct me)