From 482cde4d5b3c154d0e75b2d984d19253a8ccfdc9 Mon Sep 17 00:00:00 2001 From: sspanak Date: Fri, 17 May 2024 12:06:59 +0300 Subject: [PATCH] fixed virtual Backspace not working in limited text fields --- .../sspanak/tt9/ui/main/keys/SoftBackspaceKey.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftBackspaceKey.java b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftBackspaceKey.java index 449a6df7..e9a9a852 100644 --- a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftBackspaceKey.java +++ b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftBackspaceKey.java @@ -2,6 +2,7 @@ package io.github.sspanak.tt9.ui.main.keys; import android.content.Context; import android.util.AttributeSet; +import android.view.KeyEvent; import io.github.sspanak.tt9.languages.LanguageKind; import io.github.sspanak.tt9.util.Characters; @@ -27,7 +28,15 @@ public class SoftBackspaceKey extends SoftKey { @Override final protected boolean handleHold() { - return validateTT9Handler() && tt9.onBackspace(); + if (validateTT9Handler() && !tt9.onBackspace()) { + // Limited or special numeric field (e.g. formatted money or dates) cannot always return + // the text length, therefore onBackspace() seems them as empty and does nothing. This results + // in fallback to the default hardware key action. Here we simulate the hardware BACKSPACE. + tt9.sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL); + return true; + } + + return false; } @Override