From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mouse position within a string control/indicator

Solved!
Go to solution

Hi all,

Using LabVIEW 2015 and would like to know if it's possible to do the following...

I have a string with a paragraph or two of text.  In this text, certain terms and words are highlighted (via different font color).

I would like to sense when the mouse is hovering over one of these terms and change the cursor type when it is over them.

...think hyperlinks in a browser.

 

I can sense when I'm over the string control itself, but not any specific text.

 

Any ideas?

Thanks!

Charlie

 

0 Kudos
Message 1 of 4
(3,909 Views)
Solution
Accepted by topic author asuwish4

The string control should have a method which takes coordinates (which you can get from a Mouse Down or Mouse Move event) and tells you where that is in the string. Create an invoke node for the string and select the relevant method (I think it's called Byte Offset from Point). I don't have experience with it, but I assume it compensates for things like scrolling and font sizes.


___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(3,873 Views)

Hi Charlie,

 

As a follow-up to tst's answer, after you find what byte your cursor is at (a 0-based index into the string characters), you can use property nodes to set the selection cursor to determine the font color. A small side effect is that your text caret will jump around with your mouse cursor.

 

In the code snippet, if the character byte determined from the mouse pointer is more than the number of characters, the text color is default to white.

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
Message 3 of 4
(3,844 Views)

Thank you guys!

 

You just stopped me from doing lookup tables that correlate monospace font point sizes to number of characters that fit in a row and column of a string of known, fixed dimensions.

 

Thanks again!

Charlie

 

 

0 Kudos
Message 4 of 4
(3,809 Views)