Jiri Bruchanov
05/12/2021, 8:46 PM@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:
OTF:-
OTF:-a
OTF:-ab
OTF:-abc
OTF:-abcd
OTF:-abcde
OTF:-abcde1
OTF:-abcde12
OTF:-abcde123
OTF:-abcde1234
Trying to do same thing with the TextField just works as expected.
What am I missing here ?tad
05/13/2021, 4:24 AMtext = v.filter { it in '0'..'9' }
to avoid the branchChar.isDigit
would also work but Java has a wild definition of "digit"... :))