In my UI I want that keyboard events Up/Down shoul...
# compose-desktop
r
In my UI I want that keyboard events Up/Down should be handled by the main scrollable list. This works but clicking on other elements can remove the focus. How do you implement such logic?
k
Perhaps rewording the second part will help. Is it a statement that sometimes clicking removes the focus? Or is it a question on how to combine custom key handling with focus handling? Also, is this happening in Material components? In Jewel? In your custom list?
r
I want to keep the focus on the list. The screen consists of a Material3 Rail, a Column containing a top Row with buttons and a Box containing a Column with LazyColumn and VerticalScrollBar. The LazyColumn has Cards with buttons. Both the buttons in the top Row and the cards grab focus, even if the UI state has a FocusRequester that gets remembered and the list calls Modifier.focusRequester(). I would be interested in example code for this kind of problem.
a
You can make the buttons non-focusable with
Copy code
Modifier.focusProperties { canFocus = false }
r
This works, thank you. The top bar buttons still grab focus but this is likely because the list is redrawn and some state changes.