DS Server

Javascript: TextFieldCollection.getItem Method

Method|Introduced in 28.0

Description

Gets the text field at the current text input position or the text field with the specified id.

Syntax

<void> TextFieldCollection.getItem(<RequestTextFieldCallback> callback, [<ErrorCallback> errorCallback], [<number> id])

Parameters

ParameterDescription
callback

The callback function that receives the requested value.

errorCallback

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

id

Optional. Specifies the text field's identifier set with the ID property. The method returns null if a text field with the specified identifier does not exist.

Examples

The following example demonstrates TextFieldCollection.getItem in a practical document-editing workflow. It gets the text field at the current text input position or the text field with the specified id.

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

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