Interface

InputTransformation

A function that is ran after every change made to a [TextFieldState] by user input and can change or reject that input.

Overload 1

Common
fun interface InputTransformation

A function that is ran after every change made to a TextFieldState by user input and can change or reject that input.

Input transformations are ran after hardware and software keyboard events, when text is pasted or dropped into the field, or when an accessibility service changes the text.

To chain filters together, call then.

Prebuilt filters are provided for common filter operations. See:

  • InputTransformation.maxLength()
  • InputTransformation.allCaps()

Properties

Common
val keyboardOptions: KeyboardOptions?

Optional KeyboardOptions that will be used as the default keyboard options for configuring the IME. The options passed directly to the text field composable will always override this.

Functions


applySemantics

fun SemanticsPropertyReceiver.applySemantics() = Unit

Optional semantics configuration that can update certain characteristics of the applied TextField, e.g. SemanticsPropertyReceiver.maxTextLength.


transformInput

fun TextFieldBuffer.transformInput()

The transform operation. For more information see the documentation on InputTransformation.

This function is scoped to TextFieldBuffer, a buffer that can be changed in-place to alter or reject the changes or set the selection.

To reject all changes in the scoped TextFieldBuffer, call revertAllChanges.

When multiple InputTransformations are linked together, the transformInput function of the first transformation is invoked before the second one. Once the changes are made to TextFieldBuffer by the initial InputTransformation in the chain, the same instance of TextFieldBuffer is forwarded to the subsequent transformation in the chain. Note that TextFieldBuffer.originalValue never changes while the buffer is passed along the chain. This sequence persists until the chain reaches its conclusion.