Is there a way to keep the keyboard visible while ...
# compose
c
Is there a way to keep the keyboard visible while displaying a dialog on top of it? Currently if the keyboard is displayed and then I trigger a dialog to show it hides the keyboard. I want it to stay open
s
With Compose, the keyboard is shown when a component like a
TextField
is focused. If it loses focus, the keyboard will hide. Are you trying to type in a text field in the dialog? If so, focus it when the dialog is shown.
c
I want to keep the focus on the textfield below the dialog. The dialog just pops up with 2 buttons and they can dismiss it. There's some trickery surrounding this with setting flags on the dialog's window https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/visibility#showOnTopIme_dialog Which I was able to find a hack to setting that flag via
Copy code
(LocalView.current.parent as DialogWindowProvider).window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM)
seems to work? 🤞 not sure how bad this hack is though
s
Does the input still go into the text field? I think it would work if you capture focus on the text field when the dialog is launched, then free it on dismiss (if you want to allow the user to change the focus)
c
the focus is still on the textfield but with that flag you can't interact with the textfield. This is the functionality I was looking for. AFAIK focus has no effect on making the keyboard stay on screen or not when a dialog is opened