LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing text colours on a boolean control

Hi,

I am trying to create a boolean control typedef where the colour of the boolean text changes when the button is clicked, for example in the image below:

example_boolean_controls.PNG

The background of the button is an image, but the text is loaded dynamically, so can not be part of the image.  There is not a option in the properties to change the true/false text colour, but it can be changed by property node.  I have hundreds of these buttons all with different text so do not want to have to set the properties programatically using property nodes.  Is there a way to set the appearance as I want without having to set it for every button using a property node?

 

Thanks,

 

Neil

Neil
Certified Labview Developer
0 Kudos
Message 1 of 21
(5,347 Views)

 

One way to do it is to have an array of references to all of the controls that you want to change and

use a for loop to set them in one go. You can add as many properties to the property node as you wish.

 

boolcol.jpg

0 Kudos
Message 2 of 21
(5,335 Views)

Hi NeilBH,

 

static text could be part of the button image.

Dynamic text has to be set on runtime (using property nodes) - as well as the color of that text...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 21
(5,332 Views)

Another neat way is to select all controls on the panel and then use the reference typecast to 'filter' the boolean controls for you. Smiley Happy

Non booleans controls cause an error case and so no attempt is made to change their boolean text colour.

 

boolcol2.jpg

0 Kudos
Message 4 of 21
(5,325 Views)

Hi NeilR, thanks for helping. I don't think I was clear enough in my description, as looking at your code, the BooltText.TextColors property node appears to change the background and foreground colour of the text in all cases, rather than the foreground colour of the text in the true and false cases.  What I want to achieve is the text colour to change on clicking the button down.

 

Thanks,

 

Neil

Neil
Certified Labview Developer
0 Kudos
Message 5 of 21
(5,318 Views)

Hi NeilBH,

 

use an event structure to detect MouseClick events for those buttons. You get a control reference for the button from the event structure data terminal and so you can set the text color for the clicked button.

 

You might think about registering events for all buttons of your GUI, this might be easier than creating an event for 100+ buttons manually...

(Do you really have a GUI with "hundreds" of those buttons?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 21
(5,313 Views)

Like this ...

 

0 Kudos
Message 7 of 21
(5,308 Views)

Or for multiple controls, following on from Gerds advice ...

Like this Smiley Happy  Although if you have 100s of controls, adding them to the event structure won't be much fun !

 

 

0 Kudos
Message 8 of 21
(5,300 Views)

Hi Neil (both of you),

 

getting the references for 100+ controls is fun (and easy) when you use the "controls[]" property of the VI front panel!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 21
(5,276 Views)

Perhaps something like this.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 10 of 21
(5,235 Views)