Compose intercept child focus

Viewed 41

Say I have a Row and I want it to intercept click events, preventing BasicTextField from gaining focus. Is it possible?

Row(
    modifier = Modifier.clickable {}
) {
    BasicTextField(...)
}
1 Answers

Using Enabled value in Textfield you can prevent BasicTextField from gaining focus.

TextField(
    value = text,
    onValueChange = { text = it},
    enabled = false,
    modifier = Modifier
        .clickable { text= "Clicked"},
    colors = TextFieldDefaults.textFieldColors(
        disabledTextColor = LocalContentColor.current.copy(LocalContentAlpha.current),
        disabledLabelColor =  MaterialTheme.colors.onSurface.copy(ContentAlpha.medium)
    )
)
Related