KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: List Form Font Color Highlight Tip
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Mac & Win
Published On: September 10, 2015

On a list form, a field's default font color is set to automatic.


This setting sets the font to black when a record is not highlighted and changed to white when highlighted so that the context can be seen properly.



When the color is not automatic, it does not change to white when highlighted, this can be problematic when the color is similar to the highlight color.



Below is a method to solve this issue:

1) From the form editor of the list form make a copy of the field(s) that will have their color modified



2) For the original field(s) go to the properties and set the font color to the desired color.

3) For the original field(s) go to the properties and set the visibility to "If record not selected"



4) For the copy field(s) set the color to White or the automatic font color when highlighted

5) For the copy field(s) set the visibility to "If record selected"

This will allow the data to be properly displayed. When the records are not highlighted the original field is displayed with the set color and the duplicate field is invisible, and vise-versa when records are selected.

Issues


There are issues with this method. The font does stay with the highlighted color when modifying or deactivating the window as shown in the examples below.


If modifying values from the list form is needed and/or if the deactivated display is not acceptable follow the steps below to solve this issue.

To solve the modifying issue:
1) Use the Forms On Load event with the OBJECT GET RGB COLORS command to obtain the colors of all the fields with modified colors and any one of the copy fields.

2) For the copy field(s) set the On Getting Focus and On Losing Focus events on

3) For each of the copy fields add code so that when On Getting Focus triggers OBJECT SET RGB COLORS is used to set the copy field to the original field's color and then On Losing Focus is used to return the field to its highlighted color.

To solve the deactivate issue:
1) Use the Forms On Load event with the OBJECT GET RGB COLORS command to obtain the colors of all the fields with modified colors and any one of the copy fields.

2) Set the On Deactivate and On Activate events for the form.

3) Add code to the form method so that when the On Deactivate triggers OBJECT SET RGB COLORS is used to set the all copy field(s) to the original field's color and then On Activate is used to return the field(s) to its highlighted color.

Example code

Example code for a simple list form with only one modified field below

Form method:
Case of
   : (Form event=On Load)
   C_LONGINT(fld1Frnt_l;fld1Back_l;hlFrnt_l;hlBack_l)
   OBJECT GET RGB COLORS(*;"S2_Field";fld1Frnt_l;fld1Back_l)
   OBJECT GET RGB COLORS(*;"S2_Field2";hlFrnt_l;hlBack_l)

   : (Form event=On Deactivate)
   OBJECT SET RGB COLORS(*;"S2_Field2";fld1Frnt_l;fld1Back_l)

   : (Form event=On Activate)
   OBJECT SET RGB COLORS(*;"S2_Field2";hlFrnt_l;hlBack_l)
End case


Field Object method:
Case of
   : (Form event=On Getting Focus)
   OBJECT SET RGB COLORS(*;"S2_Field2";fld1Frnt_l;fld1Back_l)

   : (Form event=On Losing Focus)
   OBJECT SET RGB COLORS(*;"S2_Field2";hlFrnt_l;hlBack_l)

   End case