Hi,
anyone who would know what's wrong in following example with OutlinedTextField ?
Jiri Bruchanov
05/12/2021, 8:46 PM
I have this following example to simply filter out typing just for digits.
Copy code
@Composable
fun Test2() {
Column {
var text by remember { mutableStateOf("") }
OutlinedTextField(value = text,
onValueChange = { v ->
println("OTF:$v")
if (v.isEmpty() || v.toIntOrNull() != null) {
text = v
}
})
TextField(value = text,
onValueChange = { v ->
println(v)
if (v.isEmpty() || v.toIntOrNull() != null) {
text = v
}
})
}
}
However if I try to start typing for example "-abcd1234", then I'd expect to ignore "-abcd" and just type into it "1234"
and that's not happening.
printlns: