{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

EditProcessor

public final class EditProcessor


Helper class to apply EditCommands on an internal buffer. Used by TextField Composable to combine TextFieldValue lifecycle with the editing operations.

Summary

Public constructors

Public methods

final @NonNull TextFieldValue

Applies a set of editCommands to the internal text editing buffer.

final void
reset(@NonNull TextFieldValue value, TextInputSession textInputSession)

Must be called whenever new editor model arrives.

final @NonNull TextFieldValue

Returns the current state of the internal editing buffer as a TextFieldValue.

Public constructors

EditProcessor

public EditProcessor()

Public methods

apply

public final @NonNull TextFieldValue apply(@NonNull List<@NonNull EditCommand> editCommands)

Applies a set of editCommands to the internal text editing buffer.

After applying the changes, returns the final state of the editing buffer as a TextFieldValue

Parameters
@NonNull List<@NonNull EditCommand> editCommands

EditCommands to be applied to the editing buffer.

Returns
@NonNull TextFieldValue

the TextFieldValue representation of the final buffer state.

reset

public final void reset(@NonNull TextFieldValue value, TextInputSession textInputSession)

Must be called whenever new editor model arrives.

This method updates the internal editing buffer with the given editor model. This method may tell the IME about the selection offset changes or extracted text changes.

toTextFieldValue

public final @NonNull TextFieldValue toTextFieldValue()

Returns the current state of the internal editing buffer as a TextFieldValue.