# TextInputSession

Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/input/TextInputService.kt+class:androidx.compose.ui.text.input.TextInputSession) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Common/AllAndroid/JVM
- Cmn

  ```
  class TextInputSession
  ```

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> Use PlatformTextInputModifierNode instead.

Represents a input session for interactions between a soft keyboard and editable text.

This session may be closed at any time by `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputService` or by calling `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#dispose()`, after which `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#isOpen()` will return false and all further calls will have no effect.

## Summary

| ### Public constructors |
|---|---|
| `[TextInputSession](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#TextInputSession(androidx.compose.ui.text.input.TextInputService,androidx.compose.ui.text.input.PlatformTextInputService))( textInputService: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputService, platformTextInputService: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/PlatformTextInputService )` **This function is deprecated.** Use PlatformTextInputModifierNode instead. | Cmn |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[dispose](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#dispose())()` **This function is deprecated.** Use PlatformTextInputModifierNode instead. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[hideSoftwareKeyboard](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#hideSoftwareKeyboard())()` **This function is deprecated.** Use PlatformTextInputModifierNode instead. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[notifyFocusedRect](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#notifyFocusedRect(androidx.compose.ui.geometry.Rect))(rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect)` **This function is deprecated.** Use PlatformTextInputModifierNode instead. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[showSoftwareKeyboard](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#showSoftwareKeyboard())()` **This function is deprecated.** Use PlatformTextInputModifierNode instead. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[updateState](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateState(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextFieldValue))(oldValue: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue?, newValue: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue)` **This function is deprecated.** Use PlatformTextInputModifierNode instead. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[updateTextLayoutResult](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateTextLayoutResult(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.OffsetMapping,androidx.compose.ui.text.TextLayoutResult,kotlin.Function1,androidx.compose.ui.geometry.Rect,androidx.compose.ui.geometry.Rect))( textFieldValue: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue, offsetMapping: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/OffsetMapping, textLayoutResult: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TextLayoutResult, textFieldToRootTransform: (https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Matrix) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, innerTextFieldBounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect, decorationBoxBounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect )` **This function is deprecated.** Use PlatformTextInputModifierNode instead. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#isOpen()` **This property is deprecated.** Use PlatformTextInputModifierNode instead. | Cmn |

## Public constructors

### TextInputSession

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
[TextInputSession](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#TextInputSession(androidx.compose.ui.text.input.TextInputService,androidx.compose.ui.text.input.PlatformTextInputService))(
    textInputService: TextInputService,
    platformTextInputService: PlatformTextInputService
)
```

> [!CAUTION]
> **This function is deprecated.**   
> Use PlatformTextInputModifierNode instead.

## Public functions

### dispose

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun [dispose](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#dispose())(): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Use PlatformTextInputModifierNode instead.

Close this input session.

All further calls to this object will have no effect, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#isOpen()` will return false.

Note, `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputService` may also close this input session at any time without calling dispose. Calling dispose after this session has been closed has no effect.

### hideSoftwareKeyboard

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun [hideSoftwareKeyboard](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#hideSoftwareKeyboard())(): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Use PlatformTextInputModifierNode instead.

Hide onscreen keyboard for a specific `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession`.

This call will have no effect if this session is not open.

This should be used instead of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputService#showSoftwareKeyboard()` when implementing a new editable text composable to hide the keyboard in response to events related to that composable.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | false if this session expired and no action was performed |

### notifyFocusedRect

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun [notifyFocusedRect](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#notifyFocusedRect(androidx.compose.ui.geometry.Rect))(rect: Rect): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Use PlatformTextInputModifierNode instead.

Notify the focused rectangle to the system.

The system can ignore this information or use it to for additional functionality.

For example, desktop systems show a popup near the focused input area (for some languages).

If the session is not open, no action will be performed.

| Parameters |
|---|---|
| `rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` | the rectangle that describes the boundaries on the screen that requires focus |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | false if this session expired and no action was performed |

### showSoftwareKeyboard

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun [showSoftwareKeyboard](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#showSoftwareKeyboard())(): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Use PlatformTextInputModifierNode instead.

Request showing onscreen keyboard.

This call will have no effect if this session is not open.

This should be used instead of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputService#showSoftwareKeyboard()` when implementing a new editable text composable to show the keyboard in response to events related to that composable.

There is no guarantee that the keyboard will be shown. The software keyboard or system service may silently ignore this request.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | false if this session expired and no action was performed |

### updateState

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun [updateState](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateState(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextFieldValue))(oldValue: TextFieldValue?, newValue: TextFieldValue): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Use PlatformTextInputModifierNode instead.

Notify IME about the new `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` and latest state of the editing buffer. `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateState(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextFieldValue)` is the state of the buffer before the changes applied by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateState(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextFieldValue)`.

`https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateState(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextFieldValue)` represents the changes that was requested by IME on the buffer, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateState(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextFieldValue)` is the final state of the editing buffer that was requested by the application. In cases where `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateState(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextFieldValue)` is not equal to `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateState(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.TextFieldValue)`, it would mean the IME suggested value is rejected, and the IME connection will be restarted with the newValue.

If the session is not open, action will be performed.

| Parameters |
|---|---|
| `oldValue: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue?` | the value that was requested by IME on the buffer |
| `newValue: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` | final state of the editing buffer that was requested by the application |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | false if this session expired and no action was performed |

### updateTextLayoutResult

Cmn Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.6.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun [updateTextLayoutResult](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#updateTextLayoutResult(androidx.compose.ui.text.input.TextFieldValue,androidx.compose.ui.text.input.OffsetMapping,androidx.compose.ui.text.TextLayoutResult,kotlin.Function1,androidx.compose.ui.geometry.Rect,androidx.compose.ui.geometry.Rect))(
    textFieldValue: TextFieldValue,
    offsetMapping: OffsetMapping,
    textLayoutResult: TextLayoutResult,
    textFieldToRootTransform: (Matrix) -> Unit,
    innerTextFieldBounds: Rect,
    decorationBoxBounds: Rect
): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Use PlatformTextInputModifierNode instead.

Notify the input service of layout and position changes.

| Parameters |
|---|---|
| `textFieldValue: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` | the text field's `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextFieldValue` |
| `offsetMapping: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/OffsetMapping` | the offset mapping for the visual transformation |
| `textLayoutResult: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TextLayoutResult` | the text field's `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TextLayoutResult` |
| `textFieldToRootTransform: (https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Matrix) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | function that modifies a matrix to be a transformation matrix from local coordinates to the root composable coordinates |
| `innerTextFieldBounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` | visible bounds of the text field in text layout coordinates, or an empty rectangle if the text field is not visible |
| `decorationBoxBounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` | visible bounds of the decoration box in text layout coordinates, or an empty rectangle if the decoration box is not visible |

## Public properties

### isOpen

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
val isOpen: Boolean
```

> [!CAUTION]
> **This property is deprecated.**   
> Use PlatformTextInputModifierNode instead.

If this session is currently open.

A session may be closed at any time by `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputService` or by calling `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/TextInputSession#dispose()`.