Alex Styl
04/30/2024, 6:44 PMModifier.onKeyEvent {}
requires the component or its children to have focus. I tried requesting focus on the Layout itself, but it automatically moves focus on the first element, which is something I don't want. (code in 🧵 )
Is there any way I can achieve this? This is for Compose Multiplatform (same behavior on Web + Desktop)Alex Styl
04/30/2024, 6:45 PMval focusManager = LocalFocusManager.current
val groupFocusRequester = remember { FocusRequester() }
Column(
Modifier.onKeyEvent {
focusManager.moveFocus(FocusDirection.Down)
true
}.focusable()
.focusRequester(groupFocusRequester)
) {
LaunchedEffect(Unit) {
groupFocusRequester.requestFocus()
}
BasicText("1", Modifier.clickable { })
BasicText("2", Modifier.clickable { })
BasicText("3", Modifier.clickable { })
}