androidx.compose.foundation.text.handwriting


Extension functions summary

Modifier

Configures an element to act as a stylus handwriting delegate which can handle text input from a handwriting session which was triggered by stylus handwriting on a handwriting delegator.

Modifier

Configures an element to act as a handwriting delegator which detects stylus handwriting and delegates handling of the recognised text to a handwriting delegate.

Extension functions

handwritingDelegate

fun Modifier.handwritingDelegate(): Modifier

Configures an element to act as a stylus handwriting delegate which can handle text input from a handwriting session which was triggered by stylus handwriting on a handwriting delegator.

When this element gains focus, if there is an ongoing stylus handwriting delegation which was triggered by stylus handwriting on a handwriting delegator, this element will receive text input from the handwriting session via its input connection.

A common use case is a component which looks like a text input field but does not actually support text input itself, and clicking on this fake text input field causes a real text input field to be shown. To support handwriting initiation in this case, a handwritingDelegator modifier can be applied to the fake text input field to configure it as a delegator, and this modifier can be applied to the real text input field. The callback implementation for the fake text field's handwritingDelegator modifier is typically the same as the onClick implementation its clickable modifier, which shows and focuses the real text input field.

This function returns a no-op modifier on API levels below Android U (34) as stylus handwriting is not supported.

handwritingDelegator

fun Modifier.handwritingDelegator(callback: () -> Unit): Modifier

Configures an element to act as a handwriting delegator which detects stylus handwriting and delegates handling of the recognised text to a handwriting delegate.

Stylus movement on the element will start a handwriting session, and trigger the callback. The callback implementation is expected to show and focus a handwriting delegate element which can handle the recognized text from the handwriting session.

A common use case is a component which looks like a text input field but does not actually support text input itself, and clicking on this fake text input field causes a real text input field to be shown. To support handwriting initiation in this case, this modifier can be applied to the fake text input field to configure it as a delegator, and a handwritingDelegate modifier can be applied to the real text input field. The callback implementation is typically the same as the onClick implementation for the fake text field's clickable modifier, which shows and focuses the real text input field.

This function returns a no-op modifier on API levels below Android U (34) as stylus handwriting is not supported.

Parameters
callback: () -> Unit

a callback which will be triggered when stylus handwriting is detected