---
title: "setSelection"
description: "Action to set text selection by character index range.

If this action is provided, the selection data must be provided using [textSelectionRange]."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun SemanticsPropertyReceiver.setSelection(
    label: String? = null,
    action: ((startIndex: Int, endIndex: Int, relativeToOriginalText: Boolean) -> Boolean)?,
)
```


Action to set text selection by character index range.

If this action is provided, the selection data must be provided using `textSelectionRange`.

#### Parameters

| | |
| --- | --- |
| label | Optional label for this action. |
| action | Action to be performed when the `SemanticsActions.SetSelection` is called. The parameters to the action are: `startIndex`, `endIndex`, and whether the indices are relative to the original text or the transformed text (when a `VisualTransformation` is applied). |




