4D v13.4Multi-style (Rich text area) |
||
|
4D v13.4
Multi-style (Rich text area)
Multi-style (Rich text area)
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: 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. Specific options in the Property list configure rich text functioning. The attributes available are font, size, style, text color and (Windows only) background color. To modify style attributes in a rich text area, there are two different possibilities:
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 OBJECT Get plain text command retrieves raw text without style tags. Note: You cannot use rich text areas in the following contexts: entry filters, quick reports and the label editor. 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. For example, here is a text that includes a style modification: 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. This pop-up menu offers standard text editing commands (cut, copy, paste) as well as commands for supported style modifications: font, size, style, color and (Windows) background color: When the user modifies a style attribute via this pop-up menu, 4D generates the On After Edit form event. Notes:
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:
In other cases, the styles will be kept according to the context. The commands that can be used to manipulate text objects by programming do not take any style tags integrated into the text into account. They act upon displayed text so they function as in previous versions of 4D. This concerns the following commands: Note that when you use these commands with commands that manipulate character strings, it is necessary to filter the formatting characters using the OBJECT Get plain text command: HIGHLIGHT TEXT([Products]Notes;1;Length(OBJECT Get plain text([Products]Notes))+1)
If the "Store with default style tags" option is checked for the object, the use of these commands will cause a modification of the tags saved with each object. When it is used with a rich text area, the Get edited text command (Form Events theme) returns the text of the current area including any style tags. To retrieve the "plain" text (text without tags) being edited, you must use the OBJECT Get plain text command: OBJECT Get plain text(Get edited text) Queries and sorts carried out among multi-style objects take into account any style tags saved in the object. If a style modification has been made within a word, searching for the word will not be successful. To be able to carry out valid searches and sorts, you must use the OBJECT Get plain text command. For example: QUERY BY FORMULA([MyTable];OBJECT Get plain text([MyTable]MyFieldStyle)="very well") This paragraph lists the attributes of <SPAN> tags that are supported by 4D in rich text areas. You can use these tags to implement custom style handling. Only the tags listed below are supported by 4D for style variations. <SPAN STYLE="font-family: DESDEMONA"> ... </SPAN> <SPAN STYLE="font-size: 20pt"> ... </SPAN>
<SPAN STYLE="color:green"> ... </SPAN> <SPAN STYLE="background-color:green"> ... </SPAN> Note: Under Mac OS, this attribute is ignored. It is removed when the object is modified. For font color and background color attributes, the color value can be either the hexadecimal code for an RGB color, or the name of one of the 16 HTML colors defined for standard CSS by the W3C: |
PROPERTIES
Product: 4D TAGS texte riche, rich text area*** |