@@ -323,6 +323,9 @@ private void printConfig(EGL10 egl, EGLDisplay display,
323323
324324 private PowerManager .WakeLock wakeLock ;
325325
326+ // This stores the length of the text in pridiction/swype buffer
327+ private int mDelLen = 0 ;
328+
326329 // The width and height. (This should be set at startup time -
327330 // these values just prevent segfaults and divide by zero, etc.)
328331 int mWidth = 100 ;
@@ -970,6 +973,10 @@ public boolean onTouchEvent(final MotionEvent event) {
970973 @ Override
971974 public boolean onKeyDown (int keyCode , final KeyEvent event ) {
972975 //Log.i("python", String.format("key down %d", keyCode));
976+ if (mDelLen > 0 ){
977+ mDelLen = 0 ;
978+ return true ;
979+ }
973980 if (mInputActivated && nativeKey (keyCode , 1 , event .getUnicodeChar ())) {
974981 return true ;
975982 } else {
@@ -979,6 +986,10 @@ public boolean onKeyDown(int keyCode, final KeyEvent event) {
979986
980987 @ Override
981988 public boolean onKeyUp (int keyCode , final KeyEvent event ) {
989+ if (mDelLen > 0 ){
990+ mDelLen = 0 ;
991+ return true ;
992+ }
982993 //Log.i("python", String.format("key up %d", keyCode));
983994 if (mInputActivated && nativeKey (keyCode , 0 , event .getUnicodeChar ())) {
984995 return true ;
@@ -991,6 +1002,10 @@ public boolean onKeyUp(int keyCode, final KeyEvent event) {
9911002 public boolean onKeyMultiple (int keyCode , int count , KeyEvent event ){
9921003 String keys = event .getCharacters ();
9931004 char [] keysBuffer = new char [keys .length ()];
1005+ if (mDelLen > 0 ){
1006+ mDelLen = 0 ;
1007+ return true ;
1008+ }
9941009 if (keyCode == 0 ){
9951010 // FIXME: here is hardcoed value of "q" key
9961011 // on hacker's keyboard. It is passed to
@@ -1042,11 +1057,10 @@ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
10421057 outAttrs .imeOptions = EditorInfo .IME_FLAG_NO_EXTRACT_UI ;
10431058 return new BaseInputConnection (this , false ){
10441059
1045- private int mDelLen = 0 ;
10461060
10471061 private void deleteLastText (){
10481062 // send back space keys
1049- for (int i = 0 ; i < this . mDelLen ; i ++){
1063+ for (int i = 0 ; i < mDelLen ; i ++){
10501064 nativeKey (KeyEvent .KEYCODE_DEL , 1 , 23 );
10511065 nativeKey (KeyEvent .KEYCODE_DEL , 0 , 23 );
10521066 }
@@ -1065,7 +1079,7 @@ public boolean setComposingText(CharSequence text,
10651079 nativeKey (45 , 0 , (int ) c );
10661080 }
10671081 // store len to be deleted for next time
1068- this . mDelLen = text .length ();
1082+ mDelLen = text .length ();
10691083 return super .setComposingText (text , newCursorPosition );
10701084 }
10711085
@@ -1074,7 +1088,7 @@ public boolean commitText(CharSequence text, int newCursorPosition) {
10741088 // some code which takes the input and manipulates it and calls editText.getText().replace() afterwards
10751089 //Log.i("Python:", String.format("Commit Text %s", text));
10761090 this .deleteLastText ();
1077- this . mDelLen = 0 ;
1091+ mDelLen = 0 ;
10781092 return super .commitText (text , newCursorPosition );
10791093 }
10801094 };
0 commit comments