LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to change text color on Global Indicator

I'm trying to change the text color and text background on a string indicator that is part of a global front panel.  I found a way to reference the global to get an actual property node associated to the global variable (no small feat), but the "text" category appears to be missing from the available property choices.
 
I can change the colors of the "Label" and the "Caption" but not the actual field value.  I can't believe Labview would let you change the Label and not the actual field itself???  This seems crazy but I'm not sure that I'm just missing something.  Can anyone tell me how to alter the Text color and Text background color for a global indicator, or am I just out of luck? 
 
The properties I need to change are Text.Textcolor and Text.TextBG.  The problem is that the "Text" category is not listing for the global variable/indicator.   Thanks.
0 Kudos
Message 1 of 5
(3,648 Views)
This seems weird. Are you actually trying to use a global as an indicator for the end user? I always thought globals are for use by code. 😉
 
Notice that globals don't have e.g. windows appearance or execution options.
0 Kudos
Message 2 of 5
(3,642 Views)
Hi bstedwel,

I think you pretty much have it, but you might just be missing a step.  Just to confirm that we are on the same page, you opened a VI reference to the Global VI, obtained a reference to the fron panel, obtained references to the controls on the VIs front panel, and then are trying to set the properties on these individual control references?  The step that you are likely missing is that you need to cast your control references to the specific controls that they correspond to.  The generic Control class does not have a property for Text fields because not all controls have text (boolean controls for one), so you will need to use the To More Specific Class function (Programming»Application Control).  In the Target Class input, you will want to create a constant for a String control/indicator reference.  Make sure that all of the references you are performing this operation to are all of String type though.  From here, you will then be able to use your String control reference to set the Text properties you are looking for.  Even so, is there a particular reason you need to programmatically change the properties of an indicator in a Global?  There may be a better approach to this, and we might be able to suggest them if you can go into what you are trying to accomplish overall.  Let me know if this helps!

Thaison V
Applications Engineer
National Instruments

0 Kudos
Message 3 of 5
(3,618 Views)

Thank you Thaison V,

Your note provided the missing link.   I tried what you described and it works! 

I do have a question however, my property node that is related to the Global front panel (in the chain) is set to "Controls[]" and outputs an array of references for the entire front panel controls/indicators.  I do have some non-string objects that I don't want to reference.   Is there an easy way to make the output array just the string indicators?  Or is there an easy way to match the reference numbers to the string indicators I'm interested in changing?  I'm not sure how to find the proper index, except to do one at a time and note the position in the reference array (of all controls/indicators) and handle the ones I desire to change in a case loop.   Is this the best or only approach?

As to why I'm doing this programatically - ( I'm new to globals so this may be completely the wrong approach - I don't know).  What I have is a front panel with a mix of string indicators, boolean lights, and some buttons.  I have a need to change the front panel from a variety of sub vi's so I made the front panel global.   In my application I need to invert the text and text background colors based on a button the user selects, but only on the string indicators.   This is actually a day/night mode feature on an in-vehicle PDA application.  During the day I have Black text on a white background (which works great during the day) but is too bright at night (even with dimming the PDA through hardware).  So I need to switch to White text on a black background at night (when the user hits the day/night mode button).  If there is a better way to reference a front panel indicator from a variety of sub vi's, I'm open to a better suggestions.

What you provided me in your note however allowed me the final puzzle piece to make this work the way I envisioned.  Thanks again for your help.

 

0 Kudos
Message 4 of 5
(3,606 Views)
bstedwel,

I'm glad I could help!  Using the Controls[] approach gives you references to all the controls and indicators on your front panel, and sounds like you only need references to the string indicators.  You can get individual references to each control by right-clicking on the control and selecting Create»Reference.  This may be tedious to deal with all of these individual references though.  What you could do is use a cluster to help with grouping.  You can group all of your string indicators into a cluster, get the individual reference to the cluster (right-click,
Create»Reference), pass the reference into a property node, and get the references to all of the controls in the cluster.  Since your non-string indicator controls are not in this cluster, they will not be in the Controls[] array.  Lastly, you could include all of your controls in the cluster, and use cluster ordering to determine the order that the Controls[] array uses.  When you place objects into a cluster, you can right-click the cluster and select Reorder Controls In Cluster... .  The order you determine here will determine the order that the Controls[] array will index its items.  If there is a better approach I can think of, I will let you know, but this should get you started at least.  Have a great day!

Thaison
Applications Engineer
National Instruments

0 Kudos
Message 5 of 5
(3,571 Views)