# Javascript: BarcodeCollection.addWithMouse Method

> Inserts a barcode with the built-in mouse interface. The barcode's size is determined through the end-user. A cross cursor indicates where the barcode 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: BarcodeCollection.addWithMouse Method
- **497 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/barcodecollection/addwithmouse-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/barcodecollection/addwithmouse-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/barcodecollection/addwithmouse-method/llms-full.txt

---

### Description

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

### Syntax

```javascript
<void> BarcodeCollection.addWithMouse(<BarcodeType> barcodeType, <string> text, <FrameInsertionMode> insertionMode, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| barcodeType | The barcode type. |
| text | The text the barcode should encrypt. |
| insertionMode | Specifies how the text flow is handled. |
| callback | Optional. Is called when the operation successfully started. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `BarcodeCollection.addWithMouse` in a practical document-editing workflow. It inserts a barcode with the built-in mouse interface. The barcode's size is determined through the end-user. A cross cursor indicates where the barcode 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;
}

function addWithMouse(barcodeType) {
    TXTextControl.barcodes.addWithMouse(
        barcodeType,
        "Quarterly report",
        TXTextControl.FrameInsertionMode.AsCharacter,
        function() {
            console.log("add with mouse completed.");
        },
        onTxError
    );
}
```

---

## Nearby

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