🌈 Create new beautiful Compose Gradients with our new wesite ->
Function

establishTextInputSession

Starts a new text input session and suspends until the session is closed.

establishTextInputSession

Source set: Common
public suspend fun PlatformTextInputModifierNode.establishTextInputSession(
    block: suspend PlatformTextInputSessionScope.() -> Nothing
): Nothing

Starts a new text input session and suspends until the session is closed.

The block function must call PlatformTextInputSession.startInputMethod to actually show and initiate the connection with the input method. If it does not, the session will end when this function returns without showing the input method.

If this function is called while another session is active, the sessions will not overlap. The new session will interrupt the old one, which will be cancelled and allowed to finish running any cancellation tasks (e.g. finally blocks) before running the new block function.

The session will be closed when:

  • The session function throws an exception.
  • The requesting coroutine is cancelled.
  • The session may remain open when:

  • Another session is started via this method, either from the same modifier or a different one.
  • OS version. Android platform may intermittently close the active connection to immediately start it back again. In these cases the session will not be prematurely closed, so that it can serve the follow-up requests.

  • The system closes the connection. This behavior currently only exists on Android depending on

This function should only be called from the modifier node's coroutineScope. If it is not, the session will not automatically be closed if the modifier is detached.

Parameters

block A suspend function that will be called when the session is started and that must call PlatformTextInputSession.startInputMethod to actually show and initiate the connection with the input method.