LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Preserving font change in a string subset

I have a program where a string subset of a string control can be different font color. If I manually type into this string control the font color is preserved. However, if I programmatically insert text at the bottom of the string control using concatenate strings, I lose my font color and all text is once again black...how can i preserve the font color?
0 Kudos
Message 1 of 23
(3,816 Views)
Hello,
 
You can change the color of your text programmatically using a property node for your string control - so you have full control over displaying your text color, and the background color of the text field in the string control.
 
Attached is a simple example.
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 23
(3,798 Views)

I don't think the answer you gave here was quite what the question is asking about (I think I have the same problem)

Basically I am monitoring a comms port and I want to distinguish between the written and read information by changing the text colour depending on direction.

 

This involves me looping to monitor the port; when I get new data going either way I need to concatenate the new data with the old, but when I do this I lose any property changes that existed on the older text.

 

Does anyone know how to concatenate and preserve the properties of the input strings?

 

Cheers

0 Kudos
Message 3 of 23
(3,492 Views)

I think what JLS has suggested will work.  I will add that you can read the properties first using the property node and then right them back to maintain the same text color and bg.  This way, you don't have to hardcore the colors in or "remember" what they were to begin with.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 4 of 23
(3,487 Views)

Is it possible for you to create a quick VI in a while loop to show the following:

While(True)

{

Concatenate(
text with colour X 

text with colour Y)

}

 

so in an output that preserves the text colour, so something like:
The dog The dog The dog The dog The dog

 

This is what i am basically trying to get, but i get the following:

Loop 1

The dog

Loop 2

The dog The dog

Loop 3

The dog The dog The dog

and so on...

 

Obviously I would change x = The to my writes and y = reads instead of constants once I can see how its done

 

 

Would really appreciate it - been banging my head on the desk all day =p

 

0 Kudos
Message 5 of 23
(3,481 Views)

Something as simple as the attached would allow you to retain the color of your text.  If your text is different colors however, I don't know that you can use two different colors once concatenated.  You may have to go with one color, but there may be a way around this.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 23
(3,471 Views)

So, on the front panel within the control you can select a certain amount of font, then set the color, and that color selection will only be applied to your selection. I tried to reproduce this on the BD but have been unable to. I have been digging through the properties, and I was hoping you could set the "selection" property (which you can) and then get a reference to your selection and set the color from there. But I see no reference to the selection. This is really a bummer, but maybe someone knows a work around.

 

If you were able to get the selection reference, you could change the selection in a loop, setting the end of the current selection to be at the next whitespace character. Then you could get/set all the words and their current colors. But, as I said, I don't currently see a way to do this.

0 Kudos
Message 7 of 23
(3,463 Views)

I did some further digging, and I don't know if you will like this idea, or how comfortable you are with active x but you could use the rich text box control. With the RTB you can set your selection, get a "selection font" reference, then set the selection color. You do all this using invoke/property nodes; Invoke to make selection, property nodes to change the color or get the current color. Does this work for you?

0 Kudos
Message 8 of 23
(3,455 Views)

@for(imstuck) wrote:

So, on the front panel within the control you can select a certain amount of font, then set the color, and that color selection will only be applied to your selection. I tried to reproduce this on the BD but have been unable to. I have been digging through the properties, and I was hoping you could set the "selection" property (which you can) and then get a reference to your selection and set the color from there. But I see no reference to the selection. This is really a bummer, but maybe someone knows a work around.

 

If you were able to get the selection reference, you could change the selection in a loop, setting the end of the current selection to be at the next whitespace character. Then you could get/set all the words and their current colors. But, as I said, I don't currently see a way to do this.


You don't need to use a reference. You can change the color of a particular section of text by first using the selections start/end and then set the font color:

 

 

If you're doing a loop then you can apply the same method to change the color by word.

Message 9 of 23
(3,450 Views)

huh, I tried this and it didn't  (apparently I did something wrong) work.

 

Edit: I used the Text.TextColors property instead of the text.FontColor property. The former sets the whole string, the latter just sets the selection. Frustrating.

0 Kudos
Message 10 of 23
(3,445 Views)