Fixed inserting emoji/digit at the current cursor position instead of at the end

This commit is contained in:
Sylvain Berfini 2025-03-03 10:22:25 +01:00
parent 990549eb24
commit 12e6de52a8

View file

@ -179,9 +179,9 @@ fun AppCompatEditText.removeCharacterAtPosition() {
@UiThread
fun AppCompatEditText.addCharacterAtPosition(character: String) {
val newValue = "${text}$character"
setText(newValue)
setSelection(newValue.length)
val start = selectionStart
text?.insert(start, character)
setSelection(start + character.length)
}
@UiThread