Fix EditBox turning black when soft keyboard hide.

I disable a optimization when users start to type, the resize layout's
doLayout event should be stoped.

But it has bugs. If we could find reliable soft keyboard show/hide
event detection method, we could enable this optimization again.
This commit is contained in:
andyque 2015-08-11 11:26:44 +08:00
parent 271ab08b59
commit b2bf8469f0
3 changed files with 9 additions and 3 deletions

View File

@ -348,7 +348,6 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
if (hasFocus) { if (hasFocus) {
Cocos2dxHelper.onResume(); Cocos2dxHelper.onResume();
mGLSurfaceView.onResume(); mGLSurfaceView.onResume();
mGLSurfaceView.requestFocus();
} }
} }
@ -357,7 +356,6 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
super.onPause(); super.onPause();
Cocos2dxHelper.onPause(); Cocos2dxHelper.onPause();
mGLSurfaceView.onPause(); mGLSurfaceView.onPause();
mGLSurfaceView.setSoftKeyboardShown(false);
} }
@Override @Override

View File

@ -204,6 +204,7 @@ public class Cocos2dxEditBox extends EditText {
switch (pKeyCode) { switch (pKeyCode) {
case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_BACK:
Cocos2dxActivity activity = (Cocos2dxActivity)this.getContext(); Cocos2dxActivity activity = (Cocos2dxActivity)this.getContext();
//To prevent program from going to background
activity.getGLSurfaceView().requestFocus(); activity.getGLSurfaceView().requestFocus();
return true; return true;
default: default:
@ -211,6 +212,11 @@ public class Cocos2dxEditBox extends EditText {
} }
} }
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
return super.onKeyPreIme(keyCode, event);
}
public void setInputFlag(int inputFlag) { public void setInputFlag(int inputFlag) {
switch (inputFlag) { switch (inputFlag) {

View File

@ -101,7 +101,9 @@ public class Cocos2dxEditBoxHelper {
@Override @Override
public void onTextChanged(final CharSequence s, int start, int before, int count) { public void onTextChanged(final CharSequence s, int start, int before, int count) {
mFrameLayout.setEnableForceDoLayout(false); //The optimization can't be turn on due to unknown keyboard hide in some custom keyboard
// mFrameLayout.setEnableForceDoLayout(false);
mCocos2dxActivity.runOnGLThread(new Runnable() { mCocos2dxActivity.runOnGLThread(new Runnable() {
@Override @Override
public void run() { public void run() {