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: 

Programmatically move cursor inside string indicator

Hi,
I need to programmatically move the cursor within a string indicator that is filled with text. I'm using labview 6.1, how do I do that?
Message 1 of 6
(4,218 Views)
Hello,

The thing to do is browse a property node for a string indicator.  I don't have 6.1 installed on the machine I'm working on right now, but in 7.1 you can do this - here's how:

There is no "cursor position" property but there is a "text.Selection" property - it allows you to specify the text which is selected via a "start" and an "end" selection number, specified in characters.

HOWEVER, if you set "start" equal to "end" then it'll place the cursor just AFTER that character specified.  For example setting both Start and End to 1 will put the cursor just AFTER the FIRST character.

BUT WAIT... there are 2 quirks...

1. you must use a string CONTROL, not an indicator, and

2. in order to actually see the cursor there, the string control must have Key Focus - just set that property in the property node just BEFORE you set the selection start and end properties to be sure the user will actually see the cursor.

In summary, you should be able to do this if you find the properties Key Focus and text.Selection in 6.1. Checkout the screenshot!

 

I hope this helps!

Best Regards,

JLS


Message Edited by JLS on 03-19-2007 02:13 PM

Best,
JLS
Sixclear
Message 2 of 6
(4,209 Views)
Works great!  Thanks.
 
Shinling
0 Kudos
Message 3 of 6
(4,193 Views)

Small update: The owning vi (front panel) must also be the frontmost panel:

 

 

beuvink_0-1638886494116.png

 

---

25+ years long fan of LabVIEW. Be aware that NI changed their business model with great impact .
Message 4 of 6
(1,976 Views)

I just happened upon the documentation for this property: https://zone.ni.com/reference/en-XX/help/371361R-01/lvprop/txt_selection/

 

If you set the start and end to be the same, LabVIEW inserts a caret into the text. If you want to highlight the text, you must set key focus on a control before you use the Selection property.

Which confuses me a bit. It talks about highlighting as something independent of selection. Is this true and if so, what are the consequences?

 

Also, am I correct in that "inserts a caret" does not actually insert anything into the text but should be taken to mean "sets the cursor to this position"?

0 Kudos
Message 5 of 6
(1,963 Views)

This is a bit a 3-fold function as far as I understand::

  1. You can place the cursor (for some reason they call it a 'caret'). Indeed it doesn't insert anything to the text. This is the same as clicking in the string with your mouse. (start & end same value)
  2. You can select text. Same as click & drag with your mouse (start & end different value)
  3. You can modifiy text properties such as color for a text-selection. In this case first 'select' text, then set properties 'Text>Font>...' (not Text>Colors). In this case the text doesn't need to have key-focus.

beuvink_0-1638891255779.png

 

beuvink_1-1638891318745.png

 

 

---

25+ years long fan of LabVIEW. Be aware that NI changed their business model with great impact .
Message 6 of 6
(1,960 Views)