4D v14.3

Programming Notes

Home

 
4D v14.3
Programming Notes

Programming Notes  


 

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 ST Get plain text command:

 HIGHLIGHT TEXT([Products]Notes;1;Length(ST Get plain text([Products]Notes))+1)

  • Objects (Forms) 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.

 Starting with 4D v14, a new way of interacting has been defined between generic commands such as OBJECT SET RGB COLORS or OBJECT SET FONT STYLE and multi-style text areas.

In previous versions of 4D, executing one of these commands modified the contents of any custom style tags inserted in the area. From now on, only default properties are affected by these commands (as well as any properties saved by means of default tags). Custom style tags remain as they are. 

For example, given a multi-style area where default tags were saved:

The plain text of the area is as follows:

<span style="text-align:left;font-family:'Segoe UI';font-size:9pt;color:#009900">This is the word <span style="color:#D81E05">red</span></span>

If you execute the following code:

 OBJECT SET COLOR(*;"myArea";-(Blue+(256*Yellow)))

With 4D v14, the red color remains:

4D v14prior versions
<span style="text-align:left;font-family:'Segoe UI';font-size:9pt;color:#0000FF">This is the word <span style="color:#D81E05">red</span></span>
<span style="font-family:'Segoe UI';font-size:9pt;text-align:left;font-weight:normal;font-style:normal;text-decoration:none;color:#0000FF;"><span style="background-color:#FFFFFF">This is the word red</span></span>

The following generic commands are concerned:

OBJECT SET RGB COLORS
OBJECT SET COLOR
OBJECT SET FONT
OBJECT SET FONT STYLE
OBJECT SET FONT SIZE

In the context of multi-style areas, generic commands should be used to set default styles only. To manage styles during database execution, we recommend using the commands of the "" theme.

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 ST Get plain text command:

 ST 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 ST Get plain text command. For example:

 QUERY BY FORMULA([MyTable];ST Get plain text([MyTable]MyFieldStyle)="very well")

In order to ensure greater multi-platform compatibility of texts handled in the database, beginning with v14, 4D automatically normalizes line endings so that they occupy a single character: '\r' (carriage return). This normalization is carried out at the level of form objects (variables or fields) hosting plain or multi-style text. Line endings that are not native, or that use a mix of several characters (for example '\r\n'), are considered as a single '\r'.

Note that in compliance with the XML standard (multi-style text format), the multi-style text commands also normalize line endings for text variables that are not associated with objects.

This principle makes it easier to use multi-style text commands or commands such as HIGHLIGHT TEXT in a multi-platform context. However, you must take this into account in your processing when you work with texts from heterogeneous sources.

 
PROPERTIES 

Product: 4D
Theme: Styled Text

 
SEE ALSO 

OBJECT SET COLOR
OBJECT SET FONT
OBJECT SET FONT SIZE
OBJECT SET FONT STYLE
OBJECT SET RGB COLORS

 
ARTICLE USAGE

4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)