NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
Macbeth
Posts: 28

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.
Active Participant
Mr._Jim
Posts: 336

Re: change text color of string indicator

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
Member
Macbeth
Posts: 28

Re: change text color of string indicator

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.
 

Active Participant
Marc_A
Posts: 453

Re: change text color of string indicator

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.
Trusted Enthusiast
parthabe
Posts: 2,517
0 Kudos

Re: change text color of string indicator

Macbeth,

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


LabVIEW - Wires that catch bugs!
Member
Macbeth
Posts: 28
0 Kudos

Re: change text color of string indicator

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.
Active Participant RDR
Active Participant
RDR
Posts: 371
0 Kudos

Re: change text color of string indicator

This was reported to R&D (#4E99TQ5M) for further investigation.

Thanks for the feedback!

-Bob
-Bob
Active Participant
lavalava
Posts: 260
0 Kudos

Re: change text color of string indicator

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

 

 

Active Participant
Vivek_N
Posts: 366
0 Kudos

Re: change text color of string indicator

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
Active Participant
Mr._Jim
Posts: 336

Re: change text color of string indicator

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