aoriani
08/10/2022, 7:47 PMBasicTextField and its onValueChanged parameter to filter out any non-digit character. However, reading the documentation I found this :
Please keep in mind thatDoes that mean that something likeis useful to be informed about the latest state of the text input by users, however it is generally not recommended to modify the value that you get viaonValueChangecallback. Any change to this value may result in a context reset and end up with input session restart. Such a scenario would cause glitches in the UI or text input experience for users.onValueChange
var text by rememberSaveable { mutableStateOf("") }
BasicTextField(
value = text,
onValueChange = { input ->
text = input.filter { it.isDigit() }.take(5)
}
)
could be a problem because I am not passing input as is to value ?Siyamed
08/10/2022, 7:49 PMephemient
08/10/2022, 7:58 PMephemient
08/10/2022, 8:04 PMTextView you should add
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
so that the right type of soft keyboard can be shown to the user)aoriani
08/10/2022, 8:05 PMdecorationBox but not calling the innerTextField composable that is passed to it as argument, in order to implement my own visuals of the text field's value . I see people using that trick and rendering each digits as its own Text composable with border and what not. I wonder if not calling innerTextField could create problems.
My goal is to have some custom input widget. Thus I was wondering if I could leverage BasicText. Implementing a view from scratch that could interact with IME was already painful. I imagine that doing the same for a composable would be the same or worse.aoriani
08/10/2022, 8:07 PMephemient
08/10/2022, 8:19 PM