Fixed
Status Update
Comments
ra...@google.com <ra...@google.com>
ch...@gmail.com <ch...@gmail.com> #2
Any progress with the blur effect?
ma...@gmail.com <ma...@gmail.com> #3
Has there been any progress on this work? By defining "Focusable {}" the FocusOperator always seems to show the state as "Focused" for all of the children. I want to show a focused state for buttons but currently I am unable to :(.
ra...@google.com <ra...@google.com> #4
This is a high level bug to track focus work that has many bugs linked to it.
Anyway, to answer your question, we haven't made buttons focusable right now because we are still working on APIs related to TouchMode v/s NonTouchMode.
For now, you can create a focusable button like this.
@Composable
fun FocusableButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
elevation: ButtonElevation? = ButtonDefaults.elevation(),
shape: Shape = MaterialTheme.shapes.small,
border: BorderStroke? = null,
colors: ButtonColors = ButtonDefaults.buttonColors(),
contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
content: @Composable() (RowScope.() -> Unit)
) {
var borderColor by remember { mutableStateOf(Transparent) }
Button(
onClick,
modifier
.border(2.dp, borderColor)
.onFocusChanged { borderColor = if(it.isFocused) Red else Transparent }
.focusable(),
enabled,
interactionSource,
elevation,
shape,
border,
colors,
contentPadding,
content
)
}
This illustration adds an additonal red border around the button when it is focused, but you could do something else based on the focus state.
Description
Focus is a system that tracks which component is “active” in the graphical user interface. The term focus is also used as shorthand for “component that is focused/active”.
The component that is focused receives any invoked actions. These actions could be receiving text from the keyboard, receiving the contents of the clipboard during a “paste” action, or the action could also be to relinquish focus and transfer focus to another component.
The main task of the focus system is to keep track of the component that is in focus.