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

# CursorHandler

> Handler for performing simple operations with the cursor.

## Classes

### CursorHandler

#### Remarks

the TextWhizz is used as a text engine.

#### Implements

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

#### Constructors

##### Constructor

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

###### Parameters

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

###### Returns

[`CursorHandler`](#cursorhandler)

#### Accessors

##### cursorChangeEvent

###### Get Signature

```ts
get cursorChangeEvent(): EventObject<IPositionInText>;
```

Cursor change event.

###### Remarks

Reports the current cursor position.

###### Returns

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

Cursor change event.

###### Remarks

Reports the current cursor position.

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`cursorChangeEvent`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#cursorchangeevent)

#### Methods

##### getCurrentParagraphIndex()

```ts
getCurrentParagraphIndex(): number;
```

Returns the current index of the paragraph.

###### Returns

`number`

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`getCurrentParagraphIndex`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#getcurrentparagraphindex)

##### getCurrentPosition()

```ts
getCurrentPosition(): IPositionInText;
```

Returns the current cursor position.

###### Returns

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

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`getCurrentPosition`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#getcurrentposition)

##### getCurrentWord()

```ts
getCurrentWord(): ITextRange;
```

Returns the text range of the word the cursor is on.

###### Returns

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

###### Remarks

not only the current word is selected, but also the gap to the next word.

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`getCurrentWord`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#getcurrentword)

##### getFirstPosition()

```ts
getFirstPosition(): IPositionInText;
```

Returns the first position in the text.

###### Returns

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

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`getFirstPosition`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#getfirstposition)

##### getPositionByPoint()

```ts
getPositionByPoint(point): IPositionInText;
```

Returns the position in the text by point.

###### Parameters

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

###### Returns

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

###### Remarks

the cursor does not move.

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`getPositionByPoint`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#getpositionbypoint)

##### moveToDirection()

```ts
moveToDirection(direction): boolean;
```

Moves the current cursor position in the specified direction.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `direction` | [`MoveDirectionType`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/MoveDirectionType.md#movedirectiontype) | direction of cursor movement. |

###### Returns

`boolean`

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`moveToDirection`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#movetodirection)

##### setToPoint()

```ts
setToPoint(point): void;
```

Sets the cursor to a point in the text.

###### Parameters

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

###### Returns

`void`

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`setToPoint`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#settopoint)

##### setToPosition()

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

Sets the cursor at a position in the text.

###### Parameters

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

###### Returns

`void`

###### Implementation of

[`ICursorHandler`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#icursorhandler).[`setToPosition`](https://customerscanvas.com/docs/on-premises/design-atoms-js/reference/design-atoms-text/ICursorHandler.md#settoposition)
