Hi! I have a TextField that sits above a Selectabl...
# compose-desktop
g
Hi! I have a TextField that sits above a SelectableLazyColumn a bit like IDEA's Search Everywhere, and I'm wondering how I can have the SelectableLazyColumn handle keyboard events that aren't handled by the TextField while still allowing text input. I have a feeling I want to be switching focus when a key is sent to the TextField that it shouldn't handle, but I'm not really sure if this is right being new to compose. Could anyone offer me a point in the right direction?
I was able to get what I'm after with:
Copy code
val keys by derivedStateOf { items.map { SelectableLazyListKey.Selectable(it.uniqueKey) }.toList() }
    val handleListAction = { event: KeyEvent ->
        val resultListActionHandler = resultListActions.handleOnKeyEvent(event, keys, state, SelectionMode.Single)

        event.resultListActionHandler()
    }
as an
onPreviewKeyEvent
handler of the parent containing both components, though not sure if that's right either
a
Not sure specifically about the code, but handling the events in the shared parent is a decent way to do it.
Changing the focus is not a good idea.
g
ah, that's reassuring, thanks!