TX Text Control .NET Server

Javascript: TextPartCollection.activate Method

Method|Introduced in 28.0

Description

Sets the input focus to the specified text part. If the activated text part is not in the visible part of the document, the document is scrolled.

Syntax

<void> TextPartCollection.activate(<FormattedText> formattedText, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
formattedText

Specifies which formatted text will be activated.

callback

Optional. Receives true, if the specified text part could be activated. Otherwise it is false.

errorCallback

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

Examples

The following example demonstrates TextPartCollection.activate in a practical document-editing workflow. It sets the input focus to the specified text part. If the activated text part is not in the visible part of the document, the document is scrolled.

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

function activate(formattedText) {
    TXTextControl.textParts.activate(
        formattedText,
        function(result) {
            if (result) {
                console.log("activate is available.");
            } else {
                console.warn("activate is not available in the current document state.");
            }
        },
        onTxError
    );
}