Formatting and Selecting Text

You can apply formatting attributes to and retrieve formatting attributes from both characters and paragraphs in JadeRichText controls.

Although individual properties enable you to get and set both paragraph and character formatting attributes, you should consider the number of requests made to the control, particularly when running the JADE application in thin client mode. For example, calling the getCharacterFormat method involves one request from the application server but making individual calls from the application server to the presentation client for specific formatting information within the control requires seven requests.

For an example of a method that dynamically sets character and paragraph attributes at run time, see "JadeRichText Control Method Example", later in this section. See also "Formatting Selected Characters" and "Formatting Paragraphs", in the following subsections.

Formatting Selected Characters

The character formatting getCharacterFormat and setCharacterFormat methods retrieve attributes from and apply attributes to the currently selected text. If no text is selected, these methods apply to the insertion point. The character formatting of the insertion point is applied to newly inserted text if the current selection is empty. When the selection changes, the default formatting changes to match the first character in the new selection.

The text and selText properties contain plain text for the control. The textRTF and selTextRTF properties contain all rich text, including all RTF codes. Use the append or the load method to add additional plain text or RTF text to the current contents of the control. When accessing formatting attributes of selected text and the attributes have mixed values (for example, you have different font sizes in a block of selected text), the appropriate property has a value of CharacterFormat_Undefined. You cannot assign an undefined value to an attribute.

Formatting Paragraphs

Paragraph formatting attributes include alignment, tabs, indents, and numbering.

Use the getParagraphFormat and setParagraphFormat methods to retrieve and set the formatting attributes of the current paragraph. (The current paragraph is the paragraph that contains the insertion point.)