I want to get the cursor in my `CustomBasicTextFie...
# compose
c
I want to get the cursor in my
CustomBasicTextField
(request focus?) 🧵
Copy code
Row {
                BasicTextField(
                    value = value,
                    onValueChange = { value = it; onTextChange(it) },
                    ....
                )
          
            if (value.isNotBlank())
                Icon(
                    modifier = Modifier.clickable {
                        value = ""
                        onTextChange("")
//                        focus.requestFocus()
                    },
                    imageVector = Icons.Default.Clear,
                )
Basically i have a textfield with a icon to clear the text
but if the textField don't have the focus i want to request it
i try with
.focusRequester(...)
modifier, but I haven't succeeded
Copy code
@Composable
fun Custom() {
    val focusRequester = FocusRequester()

    BasicTextField(
        modifier = modifier
            .fillMaxWidth()
            .focusRequester(focusRequester)
            ...
    )

    if (value.isNotBlank())
        Icon(
            modifier = Modifier.clickable {
                value = ""
                onTextChange("")
                focusRequester.requestFocus()
            },
            imageVector = Icons.Default.Clear,
        )
}
Finally it's working... 😅