I've a problem , I'm trying to generate a VisualTransformation (Custom) similar to credit card but after that the cursor left to stay at the end of text and can't be placed a the end of text anymore:
Even if i try to move him to the end or add more text he can't be placed at the end again!!! code is (assigned to TextField) :
visualTransformation = {
TransformedText(
buildAnnotatedString {
if (it.text.isNotEmpty()){
when(it.text.length){
in 3..5 -> {
append("${java.lang.StringBuilder(it.text).insert(1,"-")}")
}
in 6..12 -> {
val tempIt=java.lang.StringBuilder(it.text).insert(1,"-")
append("${java.lang.StringBuilder(tempIt).insert(6,"-")}")
}
else -> append(it.text)
}
}
else{
append(it.text)
}
},
OffsetMapping.Identity
)
}
What I want is that the cursor always stays at the end of the text!!