I’m working on accessibility issues in my app, written in Kotlin using Jetpack Compose. I have a bug that I think I can solve if I could know when a UI component is highlighted with a TalkBack frame – in some cases, when an item’s status is selected
(an id of that item), and is also highlighted by the TalkBack frame, and I double tap it again (meaning I select it again), the selected
variable on another item gets set to the previously selected id.
What I want to achieve is making a select count only if this is the item that is currently highlighted by TalkBack. For this, I would like to know how to decide programmatically if and item is currently highlighted.
What I tried to do is to log in onFocusedChanged
modifier I attached to the component and to all other components in the screen (for control group), but no logs appear when the frame moves from item to item, so I don’t think that’s it. I did something like this:
SomeItem(
...,
modifier = Modifier.onFocusChanged {
if (it.isFocused) Log.d(...)
else if (it.hasFocus) Log.d(...)
}
)