LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

change text color of string indicator

I have a problem that I thought would be easy to solve but now I find it is not so easy.
Using LabVIEW 8.5, I have a string indicator in which there is some text displayed and I need to select some of the text and change the colors from black on white to white on black....sort of a reverse video effect.

So far I've created  a property node for the string selected "Key Focus and set it true.
Then I tried using the text.selection property to select just the characters I want.

Oddly, I find that I can select the text this way only if the string is a control and not if its an indicator.

I can't change my string indicator to a control in this case. That will break too much code.

Anybody seen this before?
Thanks.
Message 1 of 18
(13,225 Views)
Hi Macbeth,

What you're trying to do has nothing to do with key focus.  Additionally, whether or not you're dealing with a control or an indicator, you can make a property node to change font colors.

There are two places to change the font color, but only one place to change the background color.  (someone should correct me if I'm wrong.)
1.   Text->Text Color->BGColor and Text-Text Color->TextColor.  These properties change the background and text colors, respectively.
2.   Text->Font->Color

The "Text Color" and "Font Color" properties seem identical, but there's a difference.  Font properties (as opposed to text properties) allow you to select a subset.  I haven't been successful in changing a subset with text properties.

The other oddity is that you apparently can't change the text background for a subset of the string - only the whole string.  (Again, anyone jump in if I'm wrong)  So there you are - you can "reverse video" the whole string, or you can change the color of part of the string, but you can't have your cake and eat it, too.

I've attached an example VI.

Jim
Message 2 of 18
(13,215 Views)
Thanks for the answer, Jim.
I was determined to find a way to accomplish this and I was getting property node dizzy!.
I've attached a VI I was working with (LV 8.5)
It shows how a string control can be impacted but not a string indicator.
This is one cake I'd like to have a bit e out of.
 

Message 3 of 18
(13,209 Views)
There's always a way.

Use a picture control. I'm leaving work now, so I can't really be of more help, but you can display text in a picture control quite easily. You can also change colors quite easily as well. I'm not sure off the top of my head if you can set the background color of a string as you add it to the picture. If not, you would just have to draw a rectangle of the background color before you add the text.

Give it a try.
Message 4 of 18
(13,200 Views)

Macbeth,

Always use a small delay inside the while loop, else it ll eat up all your CPU resources.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 5 of 18
(13,177 Views)
You're right, Partha
I just threw that loop together quickly.
I've got to admit, though , I've given up on trying to control the text selection of a string indicator. I'll remember this issue for sure the next time I need to do something like this.
Thanks for the responses.
0 Kudos
Message 6 of 18
(13,168 Views)
This was reported to R&D (#4E99TQ5M) for further investigation.

Thanks for the feedback!

-Bob
0 Kudos
Message 7 of 18
(13,147 Views)

I used Mr. Jim example, it works pretty well but is there anyway to mulitple do highlights instead of color changes?

 

 

0 Kudos
Message 8 of 18
(12,642 Views)

Hello lavalava,

 

What exactly did you mean by 'multiple do highlights'? Could you please elaborate on your question?

Vivek Nath
National Instruments
Applications Engineer

Machine Vision
0 Kudos
Message 9 of 18
(12,622 Views)

Hi LavaLava,

 

You can change the color of more than one subset of the string, if that's what you're asking.  To accomplish this, just repeat the same properties (Text.SelStart, Text.SelEnd, and Text.FontColor) in the same property node or another one.  Essentially you're just selecting a different string subset and running the FontColor property on it, too.

 

To my knowledge, there's no way to apply BGColor or TextColor to a string subset.  (At least not on regular string controls or indicators.)  As discussed before, if you get really desperate you can use a picture control.  I don't think there's any straightforward way to get the "highlight" effect on a subset or multiple subsets of the string.  By highlight, I'm assuming you mean changing the background color?

 

I hope it helps...

 

Jim

Message 10 of 18
(12,614 Views)