Alex Styl
09/26/2025, 11:02 AM*
When I type stuff in, it works as expected, but when i press backspace once, the entire text is gone:
val state = rememberTextFieldState(value)
BasicTextField(
state = state,
outputTransformation = {
val text = state.text.toString().map { "*" }.joinToString("")
replace(0, length, text)
}
)Alex Styl
09/26/2025, 11:18 AMHalil Ozercan
09/26/2025, 11:20 AM* or entire text is replaced with a single *?Halil Ozercan
09/26/2025, 11:21 AMZach Klippenstein (he/him) [MOD]
09/26/2025, 6:46 PMAlex Styl
09/27/2025, 1:21 AM*. And when I press backspace only for the last character to be removed, not the entire textAlex Styl
09/27/2025, 1:22 AMVisualTransformation to use the new state based BasicTextFieldAlex Styl
09/27/2025, 1:24 AMTo get your behavior, you would want to replace each character individually with a separate replace call.I'll give it a go later. not sure how to do that, but i think i saw some sort of mapping property in there somwhere. thanks for the hint
Alex Styl
09/27/2025, 4:32 AMtextAlex Styl
09/27/2025, 4:32 AMHalil Ozercan
09/27/2025, 4:56 PMSkaldebane
09/27/2025, 10:54 PMreplace for each single character independently. That's how Compose knows the mapping between input and output.
Had to do the same for a Romaji to Kana converter for Japanese input.Alex Styl
09/28/2025, 2:06 PMHalil Ozercan
09/28/2025, 5:24 PMIf there's a range of inserted characters via this OutputTransformation, selection or cursor never goes in between these inserted characters.
Zach Klippenstein (he/him) [MOD]
09/28/2025, 9:50 PMiQQator
10/01/2025, 9:03 AMTextField(
password,
onValueChange = { password = it },
placeholder = { Text("Secured password field") },
visualTransformation = PasswordVisualTransformation(),
textStyle = MaterialTheme.typography.bodyMedium
)