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
Kirill Grouchnikov
11/18/2024, 9:07 PM
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
Ralf Stephan
11/19/2024, 8:36 AM
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
Alexander Maryanovsky
11/19/2024, 8:48 AM
You can make the buttons non-focusable with
Copy code
Modifier.focusProperties { canFocus = false }
r
Ralf Stephan
11/19/2024, 10:16 AM
This works, thank you. The top bar buttons still grab focus but this is likely because the list is redrawn and some state changes.