Improved and simplified 4D commands just keep coming. Now you can set colors in your form objects using CSS strings instead of numeric values. Previously CSS colors for objects were declared with a 4-byte longint (e.g., 0x00RRGGBB). But if you feel more comfortable writing BLUE instead of its numeric equivalent 255 (0xFF), we’ve got good news … 4D v17 R6 makes it possible!
This means that you now have three options when declaring a color:
$color:="#0000FF" //or #FF
The OBJECT SET RGB COLORS command now accepts string values for foreground and background colors. The code is also easier to write and to read:
OBJECT SET RGB COLORS(*;"text";"red";"Yellow")
//instead of OBJECT SET RGB COLORS(*;"text";0xFF0000;0xFFFF00)
And that’s not all! The OBJECT GET RGB COLORS command now returns CSS color values as formatted strings:
OBJECT GET RGB COLORS(*;"rectangle";$front;$back)
ALERT($front+"/ "+$back) //returns #0000FF/ #90EE90
The same concept applies to listbox-related commands. However, it’s important to note that the LISTBOX SET ROW COLOR command will transform the CSS value into a numerical value to fill the tables associated with the listbox and its columns.
Check out the documentation for more details on the supported CSS names.
Also, don’t miss the opportunity to see the updated commands in action with Roland’s HDI.