# Javascript: TextFrameCollection.addWithMouse Method

> Inserts a text frame with the built-in mouse interface. The text frame's size is determined through the end-user. A cross cursor indicates where the text frame can be inserted. Changing the document aborts the insertion process.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: TextFrameCollection.addWithMouse Method
- **333 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textframecollection/addwithmouse-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textframecollection/addwithmouse-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textframecollection/addwithmouse-method/llms-full.txt

---

### Description

Inserts a text frame with the built-in mouse interface. The text frame's size is determined through the end-user. A cross cursor indicates where the text frame can be inserted. Changing the document aborts the insertion process.

### Syntax

```javascript
<void> TextFrameCollection.addWithMouse(<TextFrameInsertionMode> insertionMode, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| insertionMode | Specifies how the text flow is handled. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `TextFrameCollection.addWithMouse` in a practical document-editing workflow. It inserts a text frame with the built-in mouse interface. The text frame's size is determined through the end-user. A cross cursor indicates where the text frame can be inserted. Changing the document aborts the insertion process.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textFrames.addWithMouse(TXTextControl.TextFrameInsertionMode.AsCharacter, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: TextFrameCollection.addInline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textframecollection/addinline-method/llms-full.txt)
- **Next:** [Javascript: TextFrameCollection.getItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textframecollection/getitem-method/llms-full.txt)
