TX Text Control .NET Server

Javascript: TextCharCollection.addControlChar Method

Method|Introduced in 28.0

Description

Inserts a control character at the specified text input position.

Syntax

<void> TextCharCollection.addControlChar(<ControlChars> controlChar, <number> textPosition, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
controlChar

Specifies a control character to insert.

textPosition

Specifies a text input position. The first input position in a document is 0.

callback

Optional. Receives whether the character is succesfully inserted.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates TextCharCollection.addControlChar in a practical document-editing workflow. It inserts a control character at the specified text input position.

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

function addControlChar(textChars) {
    textChars.addControlChar(
        TXTextControl.ControlChars.Tab,
        -1,
        function(result) {
            if (result) {
                console.log("add control char is available.");
            } else {
                console.warn("add control char is not available in the current document state.");
            }
        },
        onTxError
    );
}