Function

maxLengthReject

Rejects input changes that would cause the total length of the text field to exceed maxLength characters.

maxLengthReject

Source set: Common
public fun InputTransformation.maxLengthReject(maxLength: Int): InputTransformation

Rejects input changes that would cause the total length of the text field to exceed maxLength characters.

When text is inserted (e.g. by typing or pasting) that would cause the total length to exceed maxLength, the entire edit operation is rejected and reverted, leaving the existing text unchanged. For example, pasting "12345" into a text field that already has 8 characters and a maxLength of 10 will reject the paste completely, leaving the original 8 characters unchanged.

This transformation sets the maximum text length for accessibility services. OutputTransformation does not affect this limit. When using an OutputTransformation that adds decorating characters, set SemanticsPropertyReceiver.maxTextLength manually in a custom InputTransformation to include those characters in the announced limit.

Content updated: