TX Text Control .NET Server

Javascript: ApplicationFieldCollection.getItem Method

Method|Introduced in 28.0

Description

Gets the field at the current input position or null, if there is no such field at the current input position.

Syntax

<void> ApplicationFieldCollection.getItem(<RequestApplicationFieldCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives the found ApplicationField.

errorCallback

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

Examples

The following example demonstrates ApplicationFieldCollection.getItem in a practical document-editing workflow. It gets the field at the current input position or null, if there is no such field at the current input position.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const applicationFields = mainText.applicationFields;
    applicationFields.getItem(
        function(field) {
            if (!field) {
                console.warn("No application field was returned.");
                return;
            }
            
            console.log("get item result:", field);
        },
        onTxError
    );
}, onTxError);