DS Server

Javascript: Selection.getForeColor Method

Method|Introduced in 26.0

Description

Gets the color used to display the selected text.

Syntax

<void> Selection.getForeColor(<RequestStringCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Is called with the color used to display the selected text. The color attribute is if available the color's name else the HEX value as a string. The property's default value is the HTML Color windowtext. The property returns its default value when the text selection contains multiple characters with mixed colors.

errorCallback

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

Examples

The following example demonstrates Selection.getForeColor in a practical document-editing workflow. It gets the color used to display the selected text.

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

TXTextControl.selection.getForeColor(
    function(result) {
        console.log("get fore color result:", result);
    },
    onTxError
);