DS Server

Selection Object

Object|Introduced in 24.0

Description

Describes and handles the attributes of a text selection. Each of the properties of this class returns the property's default value if the selection does not contain a common value.

Syntax

Selection

Examples

The following example demonstrates Selection in a practical document-editing workflow. Describes and handles the attributes of a text selection. Each of the properties of this class returns the property's default value if the selection does not contain a common value.

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

TXTextControl.selection.getText(
    function(result) {
        console.log("get text result:", result);
    },
    onTxError
);

Members

Properties

PropertyDescription
listFormatGets a bulleted or numbered list and / or its formatting attributes for the selected text.
paragraphFormatGets the formatting attributes of the selected paragraphs.
sectionFormatGets page settings such as margins, size and orientation for the selected text.

Methods

MethodDescription
changeCapitalizationChanges the capitalization of all selected characters depending on the 'capitalizationParameter' parameter.
changeDirectionChanges the writing direction of all selected paragraphs. When the direction of a paragraph is changed, this paragraph's alignment is toggled from left to right or from right to left. The alignment of centered and justified paragraphs is not changed. Left and right tabulators are also toggled.
decreaseIndentDecreases the left indent of all paragraphs contained in the current text selection. If no text is selected, this method decreases the left indent at the text input position. Left indent positions are defined through the paragraphs' tab positions and the indents of the paragraphs in front and behind the paragraph with the text input position.
getAutoBaselineGets values specifying automatic sub- or superscripted text. When using automatic sub- and superscript the font is scaled and moved above or below the baseline with values defined through the font itself. Automatic sub- and superscript can be combined with a user-defined baseline which can be set with the Baseline property.
getBaselineGets the baseline alignment, in twips, of the selected text. Takes a callback function as a parameter which is called with the baseline alignment, in twips, of the selected text. Positive values moves the baseline to superscript, negative values move the baseline to subscript.
getBoldGets the bold attribute of the selected text.
getCapitalsGets values specifying wheather lowercase letters are displayed with capital letters. Lowercase letters are displayed either with capital letters of the same size or with capital letters which have a smaller size. The smaller size is either the size of the lowercase 'x' (petite caps) or the size of the lowercase 'x' + 10% (small caps).
getCharacterScalingGets or sets the style's character scaling, in percent of the average character width.
getCharacterSpacingGets the style's character spacing value, in twips. This value is added to each character. When it is negative, character spacing is reduced, otherwise it is extended.
getCultureGets the culture as a languagecode2-country / regioncode2 string value. Takes a callback function as a parameter which is called with a languagecode2-country / regioncode2 string ("de-DE", "en-US" or "en", for example) as a parameter upon receiving the selection information from the server.
getFontNameGets the font name of the selected text.
getFontSizeGets the font's size, in points, of the selected text.
getForeColorGets the color used to display the selected text.
getFormattingStyleGets the formatting style of the selected text.
getItalicGets the italic attribute of the selected text.
getLengthGets the number of selected characters.
getStartGets the starting point of selected text.
getStrikeoutGets the strikeout attribute of the selected text.
getTextGets the currently selected text.
getTextBackColorGets the background color of the selected text.
getUnderlineGets the underlining styles of the selected text.
growFontIncreases the font size of each font contained in the current text selection.If no text is selected, this method increases the font size at the text input position.
increaseIndentIncreases the left indent of all paragraphs contained in the current text selection. If no text is selected, this method increases the left indent at the text input position. Left indent positions are defined through the paragraphs' tab positions and the indents of the paragraphs in front and behind the paragraph with the text input position.
isCommonListFormatValueSelectedInforms about whether an attribute from the ListFormat.Attribute enumeration has the same value for the complete selection.
isCommonPageBorderValueSelectedInforms about whether an attribute from the PageBorder.Attribute enumeration has the same value for the complete selection.
isCommonPageMarginsValueSelectedInforms about whether an attribute from the PageMargins.Attribute enumeration has the same value for the complete selection.
isCommonPageSizeValueSelectedInforms about whether an attribute from the PageSize.Attribute enumeration has the same value for the complete selection.
isCommonPargraphFormatValueSelectedInforms about whether an attribute from the ParagraphFormat.Attribute enumeration has the same value for the complete selection.
isCommonSectionFormatValueSelectedInforms about whether an attribute from the SectionFormat.Attribute enumeration has the same value for the complete selection.
isCommonSelectionValueSelectedInforms about whether an attribute from the Selection.Attribute enumeration has the same value for the complete selection.
loadLoads text in a certain format into the current selection.
removeFormattingResets all character based formatting attributes of the selected text to its default values. If nothing or more than one paragraph is selected, all paragraph based formatting attributes are also reset.
removeInlineStylesRemoves all character based styles of the selected text so that all attributes are reset to the attributes of the paragraph style.
saveSaves the current selection in a certain format and sends the result back asynchronously by calling a given callback function.
setAutoBaselineSets values specifying automatic sub- or superscripted text. When using automatic sub- and superscript the font is scaled and moved above or below the baseline with values defined through the font itself. Automatic sub- and superscript can be combined with a user-defined baseline which can be set with the Baseline property.
setBaselineSets the baseline alignment, in twips, of the selected text.
setBoldSets the bold attribute of the selected text.
setBoundsObsolete. This method will be removed in one of the next versions. Sets the selection's start position and length.
setCapitalsSets values specifying wheather lowercase letters are displayed with capital letters. Lowercase letters are displayed either with capital letters of the same size or with capital letters which have a smaller size. The smaller size is either the size of the lowercase 'x' (petite caps) or the size of the lowercase 'x' + 10% (small caps).
setCharacterScalingSets or sets the style's character scaling, in percent of the average character width.
setCharacterSpacingSets the style's character spacing value, in twips. This value is added to each character. When it is negative, character spacing is reduced, otherwise it is extended.
setCultureSets the culture as a languagecode2-country / regioncode2 string value.
setFontNameSets the font's name of the selected text.
setFontSizeSets the font's size, in points, of the selected text.
setForeColorSets the selection's foreground color.
setFormattingStyleSets the formatting style of the selected text.
setItalicSets the italic attribute of the selected text.
setLengthSets the number of selected characters.
setStartSets the starting point of selected text.
setStrikeoutSets the strikeout attribute of the selected text.
setTextSets the currently selected text.
setTextBackColorSets the selection's background color.
setUnderlineSets the underlining styles for the selected text.
shrinkFontDecreases the font size of each font contained in the current text selection. If no text is selected, this method decreases the font size at the text input position.

Enumerations

EnumerationDescription
AttributeDetermines a certain selection attribute.