05-27-2015 04:57 PM
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.
Solved! Go to Solution.
05-27-2015 05:20 PM
05-27-2015 05:30 PM
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.
05-27-2015 05:59 PM
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?
05-27-2015 07:41 PM
05-27-2015 07:51 PM
05-27-2015 07:56 PM
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.
05-27-2015 08:14 PM
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
05-27-2015 08:36 PM
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.
05-27-2015 09:44 PM