FocusDirection
value class FocusDirection internal constructor(private val value: Int)
The FocusDirection
is used to specify the direction for a FocusManager.moveFocus
request.
Companion Object
Properties
val Next: FocusDirection
Direction used in FocusManager.moveFocus
to indicate that you are searching for the
next focusable item.
val Previous: FocusDirection
Direction used in FocusManager.moveFocus
to indicate that you are searching for the
previous focusable item.
val Left: FocusDirection
Direction used in FocusManager.moveFocus
to indicate that you are searching for the
next focusable item to the left of the currently focused item.
val Right: FocusDirection
Direction used in FocusManager.moveFocus
to indicate that you are searching for the
next focusable item to the right of the currently focused item.
val Up: FocusDirection
Direction used in FocusManager.moveFocus
to indicate that you are searching for the
next focusable item that is above the currently focused item.
val Down: FocusDirection
Direction used in FocusManager.moveFocus
to indicate that you are searching for the
next focusable item that is below the currently focused item.
val Enter: FocusDirection
Direction used in FocusManager.moveFocus
to indicate that you are searching for the
next focusable item that is a child of the currently focused item.
val Exit: FocusDirection
Direction used in FocusManager.moveFocus
to indicate that you want to move focus to the
parent of the currently focused item.
Code Examples
MoveFocusSample
@Composable
fun MoveFocusSample() {
val focusManager = LocalFocusManager.current
Column {
Row {
Box(Modifier.focusable())
Box(Modifier.focusable())
}
Row {
Box(Modifier.focusable())
Box(Modifier.focusable())
}
Button(onClick = { focusManager.moveFocus(FocusDirection.Right) }) { Text("Right") }
Button(onClick = { focusManager.moveFocus(FocusDirection.Left) }) { Text("Left") }
Button(onClick = { focusManager.moveFocus(FocusDirection.Up) }) { Text("Up") }
Button(onClick = { focusManager.moveFocus(FocusDirection.Down) }) { Text("Down") }
}
}