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

galex

08/08/2020, 12:56 PM
How can I close the software keyboard in onClick on a button? I can see we get
softwareKeyboardController
in
onImeActionPerformed
but what about other places? I didn’t find an Ambient for this
f

Fudge

08/08/2020, 12:58 PM
I think you need to store it in a “””lateinit””” local variable by using onKeyboardReady or something like that in TextField
You have a nullable SoftwareKeyboardController? and assign it in the callback you are given
g

galex

08/08/2020, 12:59 PM
That would work only if the imeAction was performed
f

Fudge

08/08/2020, 12:59 PM
no you get the controller earlier
There are more callbacks in textfield
g

galex

08/08/2020, 12:59 PM
Ah ok!
f

Fudge

08/08/2020, 1:00 PM
It is a dreadful pattern, i wish TextField just returned the controller somehow
g

galex

08/08/2020, 1:00 PM
onTextInputStarted
returns it, gotcha
Yes this is quite disappointing to have to do that
Worked like a charm. thank you @Fudge
2 Views