Merge pull request #6764 from minggo/monkey-test

EditBox: Check text content before being sent to cpp
This commit is contained in:
minggo 2014-05-15 18:22:35 +08:00
commit 9f67e74878
1 changed files with 19 additions and 14 deletions

View File

@ -123,25 +123,30 @@ public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListe
public boolean onEditorAction(final TextView pTextView, final int pActionID, final KeyEvent pKeyEvent) {
if (this.mCocos2dxGLSurfaceView.getCocos2dxEditText() == pTextView && this.isFullScreenEdit()) {
// user press the action button, delete all old text and insert new text
for (int i = this.mOriginText.length(); i > 0; i--) {
this.mCocos2dxGLSurfaceView.deleteBackward();
/*
if (BuildConfig.DEBUG) {
Log.d(TAG, "deleteBackward");
if (null != mOriginText) {
for (int i = this.mOriginText.length(); i > 0; i--) {
this.mCocos2dxGLSurfaceView.deleteBackward();
/*
if (BuildConfig.DEBUG) {
Log.d(TAG, "deleteBackward");
}
*/
}
*/
}
String text = pTextView.getText().toString();
if (text != null) {
/* If user input nothing, translate "\n" to engine. */
if ( text.compareTo("") == 0) {
text = "\n";
}
/* If user input nothing, translate "\n" to engine. */
if (text.compareTo("") == 0) {
text = "\n";
if ( '\n' != text.charAt(text.length() - 1)) {
text += '\n';
}
}
if ('\n' != text.charAt(text.length() - 1)) {
text += '\n';
}
final String insertText = text;
this.mCocos2dxGLSurfaceView.insertText(insertText);
/*