Jetpack Compose Textfield OnFocusChangeListener

Viewed 1550

I have a standard Textfield and I wanna know when user sets focus in it. is there a way to do that?

I tried to set clickable modifier to trigger the event when somebody clicks on it but looks like it doesn't work with TextField:

modifier = Modifier
            .clickable {
                shouldShowSearchKeyBoard.value = true
            },
1 Answers

found the answer.

modifier = Modifier
            .focusRequester(focusRequester)
            .onFocusChanged {
                if (it.isFocused) {
                    // focused
                } else {
                    // not focused
                }
            },
Related