LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Placing the Data Entry Cursor into the First Array Element

Solved!
Go to solution

This seems like it should be simple, yet I can't figure out a way to do this.

 

I want to have a dialog VI with one array. When the dialog loads I want the data entry cursor to be placed in the first element of the array so the user can start entering data with the keyboard and not have to click in it with the mouse, and then tab through the rest of the array. The "Key Focus" property node just seems to give me a box around the whole array without any data entry cursor active.

0 Kudos
Message 1 of 12
(3,529 Views)
I don't know but it is likely to be difficult since LabVIEW doesn't make any distinction between elements in the array. How about using a listbox where you can specify the cursor location by cell?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 12
(3,515 Views)
Solution
Accepted by topic author mschaf

An array control has a property called Array Element. Get a reference to it and set its key focus to true. I just spent a few minutes testing this, and it only worked for me if I first obtained the reference, then set the key focus in a second property node, rather than doing it all in one implicit property node. Also, it always sets focus to the second element of the array, which admittedly isn't too helpful. I didn't find a way around this in my brief tests, unfortunately.

0 Kudos
Message 3 of 12
(3,502 Views)

Nathand's response gets me part of the way there - it now places the data entry cursor in the active array element. Unfortunately, I can't figure out a way to set the active array element. So if I run the VI after entering a set of values by tabbing through them, it picks up where it left off, not at the beggining. How can I get it so that the cursor is placed in the first element every time?

0 Kudos
Message 4 of 12
(3,490 Views)
Unfortunately, the problem is inherent to arrays. The only difference between one element and the next is value. Elements can not be individually accessed except as values.

Have you looked at listboxes. I have done just what you are talking about with them. What kind of data are you inputting?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 12
(3,464 Views)
Solution
Accepted by topic author mschaf
Mike, I think you're misunderstanding the problem. The poster only wants to change the array element values, and wants the user to be able to enter values when the VI runs (starting at the first array element) without first clicking on the array element.

Search a bit on this forum, others have tried the same thing. I saw a description of code in one post where the code resized the array to show only one element, set the focus, then resized it back to the original dimensions - maybe that will work here?
0 Kudos
Message 6 of 12
(3,458 Views)

Nathand, I just tried what you suggested - resizing to 1 element, setting key focus, and then sizing back to normal, and it worked. Thanks for all your help on this.

0 Kudos
Message 7 of 12
(3,446 Views)

I agree with Mike.  This appears to be a situation where two different data structures are appropriate. For the User Interface the listbox is specifically designed for such purposes.  On the block diagram an array is probably the appropriate structure. The programming effort "cost" for the conversion is probably less than the time it took to find an awkward work-around.

 

Another way to deal with dialogs is to have a control to specify the array index to be changed (which can be set programmatically to an arbitrary starting value) and a control for the new value. The user enters the new value, hits Tab and enters the next value. When Tab is hit the value is updated in the block diagram array, the index value is incremented, and key focus is returned to the value control. If desired the values in the array can be displayed in an indicator for the user's convenience.

 

Lynn

0 Kudos
Message 8 of 12
(3,434 Views)

Mike and Lynn, I think the listbox would also work well, thanks for the suggestion. In my case I am going to stick with using an array since the input needs to be numeric.

0 Kudos
Message 9 of 12
(3,420 Views)
As a matter of fact the code I told you about was for the operator to enter numeric data.

The risk you are running is that the "solution" will atop working the first time you upgrade LabVIEW.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 12
(3,406 Views)