I'm trying to implement custom soft keyboard behaviour and met an issue. I overrode onCreateInputConnection() and extended BaseInputConnection class. Now I expect method commitText() gets called when a key is clicked... and it does unless the number key is clicked. The number key goes directly to sendKeyEvent() method. Is there a way to handle numeric keys like any other keys? Thanks.
Here is the onCreateInputConnection method implementation. Nothing special.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
outAttrs.inputType = InputType.TYPE_CLASS_NUMBER;
outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE;
return new BaseInputConnection(this, true) {
@Override
public Editable getEditable() {
return editable;
}
@Override
public boolean commitText(CharSequence text, int newCursorPosition) {
return super.commitText(text, newCursorPosition);
}
@Override
public boolean sendKeyEvent(KeyEvent event) {
return super.sendKeyEvent(event);
}
};
}