OutputTransformation

Interface

Common
fun interface OutputTransformation

A function (transformOutput) that transforms the text presented to a user by a BasicTextField.

Functions

fun TextFieldBuffer.transformOutput()

Given a TextFieldBuffer that contains the contents of a TextFieldState, modifies the text. After this function returns, the contents of the buffer will be presented to the user as the contents of the text field instead of the raw contents of the TextFieldState.

Use this function to change the visual and semantics representation of the text. For example, a phone number field can format the raw input by adding parentheses and white spaces in between characters.

The result of this transformation is purely representational and does not affect the contents of TextFieldState.

Selection and cursor positions are managed internally by BasicTextField. If there's a range of inserted characters via this OutputTransformation, selection or cursor never goes in between these inserted characters. Furthermore, changing the selection or cursor position of this TextFieldBuffer does not have any affect. Please use InputTransformation or TextFieldState.edit to manipulate the current selection placement.

Note that this transformation is called every time a new text needs to be displayed. This implies that the contents of TextFieldBuffer will always be what the TextFieldState holds currently. All the changes made here are discarded after text is presented to the user.

You can call TextFieldBuffer.addStyle to add partial styling to the presented text.