1
0
Fork 0

fixed Backspace not deleting selected text

This commit is contained in:
sspanak 2024-09-30 13:36:03 +03:00 committed by Dimo Karaivanov
parent 77f4803dc4
commit 7fb509604e
3 changed files with 16 additions and 2 deletions

View file

@ -135,7 +135,16 @@ public abstract class TypingHandler extends KeyPadHandler {
suggestionOps.commitCurrent(false); suggestionOps.commitCurrent(false);
mInputMode.reset(); mInputMode.reset();
int charsToDelete = settings.getBackspaceAcceleration() && repeat > 0 ? Math.max(textField.getPaddedWordBeforeCursorLength(), 1) : 1; int charsToDelete;
if (settings.getBackspaceAcceleration() && repeat > 0) {
charsToDelete = Math.max(textField.getPaddedWordBeforeCursorLength(), 1);
} else if (!textSelection.isEmpty()) {
charsToDelete = textSelection.length();
textSelection.clear(false);
} else {
charsToDelete = 1;
}
textField.deleteChars(charsToDelete); textField.deleteChars(charsToDelete);
} }

View file

@ -177,7 +177,7 @@ public class TextField extends InputField {
* "deleteSurroundingText()" to delete a region of text or a Unicode character. * "deleteSurroundingText()" to delete a region of text or a Unicode character.
*/ */
public void deleteChars(int numberOfChars) { public void deleteChars(int numberOfChars) {
if (numberOfChars < 0 || connection == null) { if (numberOfChars <= 0 || connection == null) {
return; return;
} }

View file

@ -52,6 +52,11 @@ public class TextSelection {
} }
public int length() {
return Math.abs(currentEnd - currentStart);
}
public void selectAll() { public void selectAll() {
if (connection != null) { if (connection != null) {
connection.performContextMenuAction(android.R.id.selectAll); connection.performContextMenuAction(android.R.id.selectAll);