Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know when a Composable like TextField gains focus?

I want to trigger a function upon my TextField's focus-gain, but I am unable to find something like a listener.

like image 576
MARSK Avatar asked Nov 18 '25 01:11

MARSK


1 Answers

You can use the onFocusChanged modifier

TextField(
    value = text,
    onValueChange = { text = it},
    modifier = Modifier.onFocusChanged {
        if (it.isFocused){
            //...
        }
    }
)
like image 180
Gabriele Mariotti Avatar answered Nov 20 '25 13:11

Gabriele Mariotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!