The following event handler displays the color dialog to choose a color in a color scheme:

function backgroundColorButton_onClick

   private rgbValue // Use private for &macro 

   rgbValue = getcolor() 

   if rgbValue # "" 

      form.colorscheme1.rowset.fields[ "BACKGROUND" ].value = rgbValue 

      define color SAMPLE_BG &rgbValue 

      form.sampleBackground.colorNormal = "SAMPLE_BG" 

   endif 

If a color is chosen, the RGB string is stored in a field in a color scheme table, but the row is not saved, in case the user changes their mind. A sample color is defined (or redefined), and a sample rectangle’s color is set to the newly defined color.

Note that you can assign RGB values directly to a color property, but those RGB values are expected to be in hexadecimal and in BGR (blue-green-red) order, for example "0x28b473" instead of "115,180,40". It’s easier to define a custom color than to do the conversion.