FocusOrder
Deprecated Use FocusProperties instead
class FocusOrder internal constructor(private val focusProperties: FocusProperties)
Specifies custom focus destinations that are used instead of the default focus traversal order.
Secondary Constructors
constructor() : this(FocusPropertiesImpl())
Properties
var next: FocusRequester
A custom item to be used when the user requests a focus moves to the "next" item.
var previous: FocusRequester
A custom item to be used when the user requests a focus moves to the "previous" item.
var up: FocusRequester
A custom item to be used when the user moves focus "up".
var down: FocusRequester
A custom item to be used when the user moves focus "down".
var left: FocusRequester
A custom item to be used when the user requests a focus moves to the "left" item.
var right: FocusRequester
A custom item to be used when the user requests a focus moves to the "right" item.
var start: FocusRequester
A custom item to be used when the user requests a focus moves to the "left" in LTR mode and "right" in RTL mode.
var end: FocusRequester
A custom item to be used when the user requests a focus moves to the "right" in LTR mode and "left" in RTL mode.
Code Examples
CustomFocusOrderSample
@Composable
fun CustomFocusOrderSample() {
Column(Modifier.fillMaxSize(), Arrangement.SpaceEvenly) {
val (item1, item2, item3, item4) = remember { FocusRequester.createRefs() }
Row(Modifier.fillMaxWidth(), Arrangement.SpaceEvenly) {
Box(
Modifier.focusRequester(item1)
.focusProperties {
next = item2
right = item2
down = item3
previous = item4
}
.focusable()
)
Box(
Modifier.focusRequester(item2)
.focusProperties {
next = item3
right = item1
down = item4
previous = item1
}
.focusable()
)
}
Row(Modifier.fillMaxWidth(), Arrangement.SpaceEvenly) {
Box(
Modifier.focusRequester(item3).focusProperties {
next = item4
right = item4
up = item1
previous = item2
}
)
Box(
Modifier.focusRequester(item4).focusProperties {
next = item1
left = item3
up = item2
previous = item3
}
)
}
}
}