0

I'm trying to understand which element has obtained focus when I use the tab key from a external keyboard.

I'm only using composable elements in the app, mostly custom elements. I've tried to using the Layout Inspector, but that only helps if an composable has explicitly an focus attribute(parameter) exposed.

This is essential to solve since not seeing what element has focus is an accessibility issue for keyboard users.

Here is an example image of focused and non-focused elements. In my app none of my UI elements highlight that it is focused, but when I push the enter-key on the keyboard a click event is sent to the selected element. Meaning that they are gaining focus but not highlighting it.

focus states

Haroun Hajem
  • 5,223
  • 3
  • 26
  • 39
  • What are you trying to accomplish? If you want, you can use the Modifier.onFocusChanged(onFocusChanged: (FocusState) -> Unit) function to track the focused state of each element, but unless i know what you are trying to accomplish, i don't know if this is what you can use – Huib Aug 30 '22 at 07:36
  • I'm debugging an compose app and I'm trying to find out which element has focus when using a keyboard, klicking the tab-button on the keyboard. This is essential to solve since this is an accessibility issue for keyboard users. – Haroun Hajem Mar 22 '23 at 09:27

1 Answers1

0

If you activate Android's TalkBack feature you'll get a green box around the focused element.

Se example below on how it looks when activated.

Screenshot android Screenshot android focus

This will help when debugging which element has current focus.

Haroun Hajem
  • 5,223
  • 3
  • 26
  • 39