Hi! I'm having an issue while trying to use focus ...
# compose-android
v
Hi! I'm having an issue while trying to use focus with View/Compose interoperability. I have a view that's like
Copy code
<ConstraintLayout>
<Toolbar/>
<Button/>
<ComposeView/>
<Button/>
<ConstraintLayout/>
And what's happening is that once the focus enters the ComposeView, trying to navigate through pressing tab, the focus only navigates within this ComposeView. Directional navigation (pressing down) works but that's not what I want here. Does anyone know the best way to approach this?
1
The closes I got this to work on a simple test I'm doing here was defining a callback:
Copy code
val fcsCallback : () -> Unit = {
      button2.requestFocus()
   }
And do something like:
Copy code
modifier = Modifier.onPreviewKeyEvent {
    when {
        KeyEventType.KeyUp == it.type && Key.Tab == it.key -> {
            fcsCallback()
            true
        }
        else -> false
    }
}
On my last composable on that ComposeView. It's still buggy but the focus gets out
Showing an example of the issue
f
This issue was fixed in the newest Compose version, 1.7.5
v
Yep, bumped bom version here to the latest and it seems that it fixes things
bom_blue.webm