LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to highlight a specific element of an array

I'm having some trouble selecting which element in an array has key focus. I want to be able to selectively highlight individual elements in an array of strings and set the key focus so that the user can immediately enter the text into that specific element.

I have been able to get "selection.start" and "selection.end" to work, but when I get a reference to "array element" it always returns a reference to the last element manually clicked. This way, I can only programatically highlight different elements by manually clicking on them, which somewhat defeats the purpose.

Does anyone know if this is possible, or if I need to move to tables or something else in order to give me this functionality?

I'm using LV 6.1
on W2k.

Thanks

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 1 of 14
(12,274 Views)
To highlight an individual element, you can use Selection.Start and Selection.Size. In the attached example, I used a constant of 1 for Selection.Size but that can be changed if you need multiple continous selections highlighted. On the front panel, I right clicked the array and selected Advanced>Show Selection. I couldn't find a property that controls this
Message 2 of 14
(12,275 Views)
Thanks Dennis,

unfortunately my problem is not solved by this. I have managed to get the selection going, but my problem is that when I take an "array element" reference after selecting a particular cell, the last cell manually clicked is used, not the currently (programatically) selected cell.

To give an idea of what I want to do, I have modified the VI slightly to show this behaviour.

If anyone has any ideas how to change this I'd be very interested. I have since re-written my original code using a table. At least the "edit position" property works there.

Thanks

Shane
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 3 of 14
(12,274 Views)
Shane,
Look in the documents bellow how you can use the KeyFocus on arrays:
How Can I Switch Key Focus to Elements Inside a Cluster, Array, or Table?

Using Key Navigation on Arrays in LabVIEW


Zvezdana S.
National Instruments
0 Kudos
Message 4 of 14
(12,274 Views)
Thanks for that,

it's not >quite< what I was hoping, but I suppose it's better than nothing. Is there any way to generate these keystrokes programatically? The whole Idea is that the user doesn't have to select anything, simply type in the new value when the corresponding element in a correlated (boolean) array is selected.

If I may I'd like to make an official request that this funcionality (at least for setting keyfocus of array elements) be incorporated into future versions of LabVIEW (or is it already possible in LV7?).

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 5 of 14
(12,274 Views)
See the solution I posted here.


LabVIEW, C'est LabVIEW

Message 6 of 14
(12,274 Views)
Thanks Jean-Pierre,

This really doesn't solve my problem. Maybe I should explain again.

If the front-panel has an array of strings, clicking on one element allows you to enter text. For this to work, the individual item has to have key focus. I want to be able to control key focus programatically (not highlighting as my question actually suggests - sorry for that). I want to do things in the reverse fashion to what you have done in your example. I want to give key focus to a different cell clicking.


I found your example quite interesting, but I thought of a different (and for my liking much simpler) way. I know that the array element reference allows the code to give key focus to the last clicked item, which I have used her
e. You can also use the "array element" item to get the X and Y coordinates and size of the item, facilitating your calculations similarly to before.


I have given up on the idea at this stage. It works with Tables, and something that works doesn't need repairing.


Cheers


Shane


PS : I first posted in the other thread you pointed me to. sorry about that.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 7 of 14
(12,274 Views)
Shane,
Here is another example that highlights an array element based on the specified index.
Zvezdana S.
National Instruments
Message 8 of 14
(12,274 Views)
Zvezdana,

That's great. This is exactly what I was looking to do. I have to say though, that I think the usage of the "Array element" property node of an array should respond to a highlighted cell, not the last clicked cell. This would make the need for system DLL calls unneccessary.

Still, it's nice to know how to go about doing exactly what I was looking for.

Thanks

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 9 of 14
(12,274 Views)
I had the problem that I would like to highlight more than one cell in a 2d array.
multicolumn listbox is very slow working with large data volumes so I had to use a 2d array instead, but then I lose the possibility to highlight.
The solution I used was to bundle a LAD and control an put this in the array, takes a bit more coding but works fine. 
0 Kudos
Message 10 of 14
(11,659 Views)