1

Want to replicate this Edit Text feature Get Cursor Position in Android in Edit Text? in Android Jetpack Compose.

1 Answer 1

1

To get text field selection in compose, you need to use TextFieldValue, like this:

var textFieldValue by remember { mutableStateOf(TextFieldValue(text = "")) } TextField( value = textFieldValue, onValueChange = { textFieldValue = it }, ) 

Then you can get selection with textFieldValue.selection, for example on key event with Modifier.onKeyEvent, on button click, etc.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.