jasu
06/09/2022, 1:58 PMbrandonmcansh
06/09/2022, 2:14 PMtext and key the remembered internal one off the provided text so it recalculates when its changed.jasu
06/09/2022, 3:37 PMlilypuchi
06/09/2022, 5:36 PMEditText.setText() itself. Using it to set text doesn’t alter cursor position and we then explicitly have to call EditText.setSelection() to reposition it at the end. There’s no alternative I can think of
@Composable
fun EditText(
text: String,
modifier: Modifier = Modifier
) {
AndroidView(
modifier = modifier,
factory = {
EditText(it)
},
update = {
it.setText(text)
it.setSelection(it.length())
}
)
}
There is an alternative EditText.append() (inheriting from the extended TextView) which appends to the existing and places the cursor properly. But that’s only “append” and not “set”. So won’t recommend it anyways 😅jasu
06/10/2022, 6:43 AM