Using Color[4] Property to Set Boolean Color on LabVIEW Front Panel

Updated Mar 25, 2021

Reported In

Software

  • LabVIEW

Issue Details

I am using the Colors [4] property of a Boolean control or indicator. How can I specify the True and False case colors?

Solution

The Colors [4] property uses an array of four clusters containing two color constants each.  The two elements of each cluster are foreground and background RGB (Red, Green, Blue) colors for specific components of the Boolean control or indicator.  
  • The first cluster of the array represents the Boolean False case colors (foreground and background)
  • The second cluster of the array represents the Boolean True case colors (foreground and background)
  • The third cluster represents the colors of the True to False transition case. This is visible when the Boolean control uses the switch or latch when released mechanical actions.
  • The fourth cluster represents the colors of the False to True transition case. This is visible when the Boolean control uses the switch or latch when released mechanical actions.

Colors[4].png
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.

Additional Information

In previous versions of LabVIEW, the Colors[4] property used U32 numeric constants to set the RGB color value of the Boolean case by default. To set the colors of your Boolean control in this case you can:
  • Specify a color using these numeric constants using the RGB color code. Usually, this code is specified by a scale from 0-255 for each color.  For example, the color red is specified by the RGB code 255, 0, 0.  To use this code, convert the RGB code numbers to hexadecimal with the form RRGGBB.  You will also need to change the format of the numeric constants in the cluster from floating-point to hexadecimal.  Using the hexadecimal RGB codes, enter FF0000 (for red) and 00FF00 (for green) into the numeric constants corresponding to the case associated with each color. In this example, the False case is red and the True case is green.
  • A much more intuitive way to specify the color is by replacing the numeric constants in the cluster with color box constants.  To do this, delete the numeric constants in the cluster and place color box constants found on the All Functions»Numeric»Additional Numeric Constants palette of the block diagram.  After placing these constants in the cluster, specify the color you would like to use by clicking on the color box constant.