4D allows the use of rich text areas with individual style variations. For example, it is now possible to have words in bold, italics or color inside a text area:
![](../../picture/423161/pict423161.en.png)
This function applies to fields and variables of the Alpha and Text type as well as to list box cells. It is supported for page and list forms both for display and printing.
Note: You cannot use rich text areas in the following contexts: entry filters, quick reports and the label editor.
Specific options in the Property list configure rich text functioning.
The attributes available are font, size, style, text color and background color. To modify style attributes in a rich text area, there are two different possibilities:
- During execution, use an automatic pop-up menu (the availability of this menu is configured in the Property list).
- By programming, using the ST SET ATTRIBUTES command.
In rich text areas, style attributes are stored as <SPAN> type HTML tags. When the text area is displayed, these tags are interpreted by 4D. This means that the developer can specify and modify style attributes in a text via programming. The <SPAN> attributes supported by 4D are described below. The ST Get plain text command retrieves raw text without style tags.
For a description of the commands that manage rich text areas and the supported <span> tags, refer to the chapter in the 4D Language Reference manual.
Rich text management properties are available for enterable variables, fields and list box cells of the Alpha or Text type.
This option ("Text" theme) enables the possibility of using specific styles in the selected area. When this option is checked, 4D interprets any <SPAN> HTML tags found in the area.
By default, this option is not checked.
This option only appears when the Multi-style option is checked. It is also found in the "Text" theme.
When this option is checked, the area will store the style tags with the text, even if no modification has been made. In this case, the tags correspond to the default style. When this option is not checked, only modified style tags are stored.
For example, here is a text that includes a style modification:
![](../../picture/423234/pict423234.fr.png)
If the "Store with default style tags" option is not checked, the area only stores the modification. The stored contents are therefore:
What a <SPAN STYLE="font-size:13.5pt">beautiful</SPAN> day!
If the option is checked, the area stores all the formatting information. The first generic tag describes the default style then each variation is the subject of a pair of nested tags. The contents stored in the area are therefore:
<SPAN STYLE="font-family:'Arial';font-size:9pt;text-align:left;font-weight:normal;font-style:normal;text-decoration:none;color:#000000;background-color:#FFFFFF">What a <SPAN STYLE="font-size:13.5pt">beautiful</SPAN> day!</SPAN>
This option ("Entry" theme) only appears when the Multi-style option has been checked.
The Context Menu option activates, for the user, the possibility of calling a pop-up menu during data entry by a right-click in the area::
![](../../picture/1334594/pict1334594.en.png)
This pop-up menu provides the following commands:
- standard text editing commands (cut, copy, paste)
- Fonts...: displays the font system dialog box
- Recent fonts: displays the names of recent fonts selected during the session. The list can store up to 10 fonts (beyond that, the last font used replaces the oldest). By default, this list is empty and the option is not displayed. You can manage this list using the SET RECENT FONTS and FONT LIST commands.
- commands for supported style modifications: font, size, style, color and background color.
When the user modifies a style attribute via this pop-up menu, 4D generates the On After Edit form event.
Notes:
- It is also possible to modify styles via the ST SET ATTRIBUTES command. Note that in this case, no form event is generated.
- The "strikethrough" style is not supported under Mac OS. However, the corresponding tag can be used by programming.
The supported style attributes (font, size, style and color) are kept in the case of drag-and-drop or copy-paste of styled text between:
- different rich text areas within 4D (text variables/fields and list boxes),
- a 4D Write area and a 4D rich text area,
- an external styled text and a 4D rich text area.
In other cases, the styles will be kept according to the context.
Two new automatic functions are proposed when the mouse moves over a multi-style area:
- When it moves over a text selection, the cursor turns into an arrow:
![](../../picture/1334494/pict1334494.en.png)
![](../../picture/1334496/pict1334496.en.png)
- When it moves over a URL, a help tip containing the address appears:
![](../../picture/1334498/pict1334498.en.png)
Note: You can insert URL links using the ST INSERT URL command.