---
title: "SelectionHandler | Customer's Canvas On-Premises"
canonical: "https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/SelectionHandler/"
---

# SelectionHandler

> Handler for performing simple operations with text selection.

## Classes

### SelectionHandler

#### Remarks

the TextWhizz is used as a text engine.

#### Implements

- [`ISelectionHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#iselectionhandler)

#### Constructors

##### Constructor

```ts
new SelectionHandler(tw): SelectionHandler;
```

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tw` | [`ITextWhizzHolder`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ITextWhizzHolder.md#itextwhizzholder) |

###### Returns

[`SelectionHandler`](#selectionhandler)

#### Accessors

##### selectionChangeEvent

###### Get Signature

```ts
get selectionChangeEvent(): EventObject<ITextRange>;
```

Text selection change event.

###### Remarks

reports the currently selected text.

###### Returns

`EventObject`\<[`ITextRange`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ITextRange.md#itextrange)\>

Text selection change event.

###### Remarks

reports the currently selected text.

###### Implementation of

[`ISelectionHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#iselectionhandler).[`selectionChangeEvent`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#selectionchangeevent)

#### Methods

##### getSelectionRange()

```ts
getSelectionRange(): ITextRange;
```

Returns the currently selected text range.

###### Returns

[`ITextRange`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ITextRange.md#itextrange)

###### Implementation of

[`ISelectionHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#iselectionhandler).[`getSelectionRange`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#getselectionrange)

##### resetSelection()

```ts
resetSelection(position?): void;
```

Resets the selection of text and sets the anchor to a new position.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `position?` | [`IPositionInText`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/IPositionInText.md#ipositionintext) | new position in the text. |

###### Returns

`void`

###### Remarks

if position is null then anchor is set to null.

###### Implementation of

[`ISelectionHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#iselectionhandler).[`resetSelection`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#resetselection)

##### setSelectionByPoints()

```ts
setSelectionByPoints(startPoint, endPoint): void;
```

Sets the selection of text by starting and ending points.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `startPoint` | [IPoint](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-model/IPoint.md) | starting point. |
| `endPoint` | [IPoint](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-model/IPoint.md) | ending point. |

###### Returns

`void`

###### Implementation of

[`ISelectionHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#iselectionhandler).[`setSelectionByPoints`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#setselectionbypoints)

##### setSelectionByPositions()

```ts
setSelectionByPositions(startPosition, endPosition): void;
```

Sets the selection of text by starting and ending positions.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `startPosition` | [`IPositionInText`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/IPositionInText.md#ipositionintext) | starting position. |
| `endPosition` | [`IPositionInText`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/IPositionInText.md#ipositionintext) | ending position. |

###### Returns

`void`

###### Implementation of

[`ISelectionHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#iselectionhandler).[`setSelectionByPositions`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#setselectionbypositions)

##### setSelectionByRange()

```ts
setSelectionByRange(selection): void;
```

Sets the selection of text by a range.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `selection` | [`ITextRange`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ITextRange.md#itextrange) | start position in text. |

###### Returns

`void`

###### Implementation of

[`ISelectionHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#iselectionhandler).[`setSelectionByRange`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#setselectionbyrange)

##### setSelectionToPosition()

```ts
setSelectionToPosition(position): void;
```

Sets the selection of text to a position relative to the anchor.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `position` | [`IPositionInText`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/IPositionInText.md#ipositionintext) | new position in the text. |

###### Returns

`void`

###### Implementation of

[`ISelectionHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#iselectionhandler).[`setSelectionToPosition`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ISelectionHandler.md#setselectiontoposition)
