https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
e

Edoardo Luppi

10/01/2023, 1:31 PM
Not sure what's going wrong, but I'm trying to use a
BasicTextField
, e.g.
Copy code
@Composable
fun MyTextfield() {
  BasicTextField(
    value = "",
    onValueChange = { },
    minLines = 2,
    modifier = Modifier
      .fillMaxWidth()
      .background(Color.LightGray)
  )
}
And when run, the application doesn't let me type in that text field. Am I missing a step?
Apparently a mutable state must be used to update the value on every
onValueChange
Feels strange to make it mandatory, but I get it.
rubber duck 3
z

Zach Klippenstein (he/him) [MOD]

10/02/2023, 6:15 PM
The new
BasicTextField
will let you do something like this:
Copy code
val text = rememberTextFieldState()
BasicTextField(text)
but you’ll still have to pass something in – otherwise there’d be no way to actually know what the text is
gratitude thank you 1
e

Edoardo Luppi

10/02/2023, 6:18 PM
@Zach Klippenstein (he/him) [MOD] that looks good. I think the problem is the function signature, which isn't explicit enough in what it expects to be done. If the argument is a state, it's perfectly clear what you need to do, no docs needed
👍🏻 1