https://kotlinlang.org logo
#compose
Title
# compose
n

nglauber

12/02/2019, 5:11 AM
Dumb question: how to close the keyboard when the user press the imeAction button in a
TextField
?
Copy code
TextField(
    value = text.value,
    keyboardType = KeyboardType.Text,
    imeAction = ImeAction.Done,
    onImeActionPerformed = {
        // TODO how to close the keyboard?
    },
    onValueChange = { s -> text.value = s }
)
👍🏻 1
k

kioba

12/02/2019, 10:06 AM
you can request for the context via ambient:
Copy code
val context = +ambient(ContextAmbient)
if I remember correctly, context is enought to close the keyboard
n

nglauber

12/02/2019, 12:22 PM
yeah… you’re right 😉 thanks @kioba I asked that at 2am. Sorry for that 😄
👍 3