https://kotlinlang.org logo
f

Fabio Santo

05/17/2021, 11:52 PM
Hey everyone, I'm playing with compose for web, how do you use a
Input
composable? In need to get the value out of it, I can't find anything to hook my state to.... should I use the
ref
attribute maybe ?
j

jim

05/18/2021, 1:10 AM
Compose for Web is still in its very early stages, and it looks to me like perhaps the Input field is missing an
onChange
callback. Which, if I'm not mistaken, probably means that
Input
widget needs an additional parameter. This is probably a fairly straight-forward change for the community if you'd like to contribute by making a pull request on github. cc @Oleksandr Karpovich [JB] @Akif Abasov [JB]
🙏 3
o

Oleksandr Karpovich [JB]

05/18/2021, 6:01 AM
Hi @Fabio Santo We have some example here https://github.com/JetBrains/compose-jb/tree/master/tutorials/Web/Events_Handling#oninput It depends on the input type you have. Text Area or Text input have handlers which provide an easy access to the typed value. Input types that do not provide such a shortcut, could access:
event.nativeEvent.target.asDynamic().value
That's not convenient at all. Although could work as a workaround till we come up with a better way.
👍 1
h

hfhbd

06/03/2021, 2:22 PM
(event.nativeEvent.target as HTMLInputElement).value
works too
2 Views