4D v13.4

Multi-style (Rich text area)

Home

 
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:

  • During execution, use an automatic pop-up menu (the availability of this menu is configured in the Property list).
  • By programming, using the OBJECT SET STYLED TEXT 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 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.
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:

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:

  • It is also possible to modify styles via the OBJECT SET STYLED TEXT 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.

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)

  • Object Properties theme
    The commands that can be used to modify the style of objects (for example, OBJECT SET FONT) apply to the whole object and not to the selection.
    Note that if the object does not have the focus when the command is executed, the modification is applied simultaneously to the object (the text area) and to its associated variable. If the object does have the focus, the modification is carried out on the object but not on the associated variable. The modification is only applied to the variable when the object loses the focus. Keep this principle in mind when programming text areas. 

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>

  • Bold
    <SPAN STYLE="font-weight: bold"> ... </SPAN>
  • Italic or normal
    <SPAN STYLE="font-style: italic"> ... </SPAN>
    <SPAN STYLE="font-style: normal"> ... </SPAN>
  • Underline
    <SPAN STYLE="text-decoration: underline"> ... </SPAN>
  • Strikethrough
    <SPAN STYLE="text-decoration:line-through">...</SPAN>
    Note : The "strikethrough" style is not supported under Mac OS, but this tag can still be managed by programming.

<SPAN STYLE="color:green"> ... </SPAN> 
or
<SPAN STYLE="color:#006CCC">...</SPAN>

<SPAN STYLE="background-color:green"> ... </SPAN>
or
<SPAN STYLE="background-color:#006CCC">...</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
Theme: Properties for active objects

 
TAGS 

texte riche, rich text area***