forked from extern/Unexpected-Keyboard
Handle CANCEL touch events
Handling this event is part of the API but was never done. This caused unstoppable key-repeat. This event isn't common, the only way I found on Android 10 is to switch to the emoji keyboard while holding a key. Some apps might cause this event more often.
This commit is contained in:
parent
fadedfd58f
commit
d53ee811d9
@ -115,7 +115,7 @@ public class Keyboard2View extends View
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
_pointers.onTouchUp(event.getPointerId(event.getActionIndex()));
|
||||
break ;
|
||||
break;
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
p = event.getActionIndex();
|
||||
@ -124,11 +124,14 @@ public class Keyboard2View extends View
|
||||
KeyboardData.Key key = getKeyAtPosition(tx, ty);
|
||||
if (key != null)
|
||||
_pointers.onTouchDown(tx, ty, event.getPointerId(p), key);
|
||||
break ;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
for (p = 0; p < event.getPointerCount(); p++)
|
||||
_pointers.onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p));
|
||||
break ;
|
||||
break;
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
_pointers.onTouchCancel(event.getPointerId(event.getActionIndex()));
|
||||
break;
|
||||
default:
|
||||
return (false);
|
||||
}
|
||||
|
@ -95,6 +95,16 @@ public final class Pointers implements Handler.Callback
|
||||
}
|
||||
}
|
||||
|
||||
public void onTouchCancel(int pointerId)
|
||||
{
|
||||
Pointer ptr = getPtr(pointerId);
|
||||
if (ptr == null)
|
||||
return;
|
||||
stopKeyRepeat(ptr);
|
||||
removePtr(ptr);
|
||||
_handler.onPointerFlagsChanged();
|
||||
}
|
||||
|
||||
public void onTouchDown(float x, float y, int pointerId, KeyboardData.Key key)
|
||||
{
|
||||
KeyValue value = key.key0;
|
||||
|
Loading…
Reference in New Issue
Block a user