LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy font properties programatically

Hi,

 

How is it possible to copy text with its font properties from a string control/indicator to another?

I know that this can be performed with Ctrl-C (when the desired text is selected) an Ctrl-V (in the new location); however, how can I perform this action programmatically?

 

Thank you

 

Raymundo Cassani
0 Kudos
Message 1 of 10
(3,310 Views)

Hi Ray_Cassani,

 

please find attached file. If each letter has different color you should go through all string letter by letter and check his color.

 

Best Regards,

CaravagGIO

Message 2 of 10
(3,266 Views)

Thank you for your reply CaravagGIO, it works as expected. However, is it a way to do it in one shot as with the clipboard?

Raymundo Cassani
0 Kudos
Message 3 of 10
(3,240 Views)

I am sorry but I do not understand your question? Do you mean without a for loop? Could you please give me an example or tell me what is your application?

 

Regards,

CaravagGIO

0 Kudos
Message 4 of 10
(3,234 Views)

Yes.  Turn Destiny 1, 2, and 3 into Indicators (they are currently Controls) and simply connect them with a LabVIEW Wire to Origin 1, 2 and 3!

 

If (for some reason) you need to keep Destiny 1, 2, and 3 as Controls, and simply want to set them to look like Origin 1, 2, and 3, and don't want to use Property Nodes, you can create Local Variables (which have other Bad Features) and simply wire Origin 1 to Local Variable Destiny 1.

 

Bob Schor

 

P.S. -- if this is the answer you are seeking, please mark it as a Solution.

0 Kudos
Message 5 of 10
(3,233 Views)

Yes, I meant without the FOR loop.

 

In my application, I have a string indicator that plays the Console role, continuously different parts of my code send messages (with a specific color and size) to be printed in the string indicator. However, as in your code, for every new message I have to read character by character the previous message in the Console and then add the new message; I would like to copy the entire Old state of the Console (with its font properties), concatenate the new message and only modify the font for the last message.

 

If I concatenate the Old state with the new text and only change the font for the new message I get this (Case 1), if I utilize the same approach than in your VI I get the desired results (Case 2). But this solution is very slow, to run copyFont_modified2.vi.

 

Capture.PNG

 

Thanks

 

Raymundo Cassani
0 Kudos
Message 6 of 10
(3,220 Views)

Hi,

 

Bob_Schor, I already tried that but it does not copy the font properties (color, size) only the text content.

 

The solution that I've found, as I need colors by line is the following:

 

 

CAPTURE.png

Raymundo Cassani
0 Kudos
Message 7 of 10
(3,206 Views)

Aha, I learned something unexpected -- if the string has multiple properties, you cannot do the "simple" copying that I advocated!  Note that a uni-color, uni-attribute string will wire just fine ...

 

BS

0 Kudos
Message 8 of 10
(3,200 Views)

There is a discussion on the Idea Exchange about why the string datatype will not be extended to include the formatting information.  I did not search for it to provide a link  but I recall looking at it recently.

 

Two details:

1. Property nodes execute from top to bottom. Make sure that the Selection Start and Selection End properties are at the top of the list.

2. It may help, particularly on much longer strings, to place Defer Panel Update property nodes before (True) and after (False) the for loop. This will prevent the FP from attempting to update for each character and may improve the speed.

 

Lynn

0 Kudos
Message 9 of 10
(3,193 Views)

I think there is no way how to avoid using For Loop. Problem is in this sentence " I would like to copy the entire Old state of the Console (with its font properties)". There is no tool to copy font properties of all letters in the string.

 

As johnsold said, Defer Panel Update property node helps a lot to increase an execution speed.

 

Regards,

CaravagGIO

0 Kudos
Message 10 of 10
(3,181 Views)