Jump to content

Is there a way to Capture Array Element Event?


Minh Pham

Recommended Posts

Hi guys,

I just wondering that is anyone in here success capturing the event (eg. mouse down or double click) from an element within an array. (index returned prefered)

As LabVIEW doesnt have this option, it does have the Mouse Co-ordinate values returned which can be used but it is not the optimal way of

doing this i guess, you still have to figure out which item within the array is clicked/double-clicked and return the index so you can process a certain task

for that item (eg. change the value, or pop-up msg).

Any help is appreciated,

Regards,

Link to comment

QUOTE (Minh Pham @ Dec 21 2008, 05:39 PM)

Hi guys,

I just wondering that is anyone in here success capturing the event (eg. mouse down or double click) from an element within an array. (index returned prefered)

As LabVIEW doesnt have this option, it does have the Mouse Co-ordinate values returned which can be used but it is not the optimal way of

doing this i guess, you still have to figure out which item within the array is clicked/double-clicked and return the index so you can process a certain task

for that item (eg. change the value, or pop-up msg).

Any help is appreciated,

Regards,

If you don't worry about datatype (i.e if you use strings), you could use a listbox. Listboxes have a method "Point to Row" that inputs the mouse coordinates and outputs index. As far as I know, I don't think Arrays have a method to do that.

Otherwise, if all your array elements are unique, you could return the array element (variant), convert it and scan the original array to get the index. But as mentioned, it works only if all values of your array are unique.

Link to comment

There used to be a bit of a hack that always had promise, but had some technical issues because of it's hack status.

The jist is that you generate a reference off of an element in an array,

Register that for the mouse down or choice of event,

have an event structure handle that event and when it fires, use the CtlRef that is presented and suck out the value from the ref or whatever other info you need (although index is not one of those).

So that being said the LAVA CR might be your best bet, but I always liked this trick or the potential it possessed.

See link http://screencast.com/t/rtgvYhF7Yt7

Link to comment

QUOTE (Norm Kirchner @ Dec 22 2008, 06:32 AM)

The jist is that you generate a reference off of an element in an array,

Register that for the mouse down or choice of event,

have an event structure handle that event and when it fires, use the CtlRef that is presented and suck out the value from the ref or whatever other info you need (although index is not one of those).

There is much simpler approach. Array control has "Array element" propperty, which has Value property of variant type. Reading this property inside event structure for whole array event always gives you value of clicked array element (flattened to variant). If you want to get an index you can get reference of "Array Element" and search for it in array of references created before for your control. The last is not as trivial (AFAIK), at least dynamically.

Link to comment

QUOTE (vugie @ Dec 22 2008, 04:48 AM)

I've just figured out that in case I described when you click on index rectangle, value of array element also changes. So either hide an index rectangle or check whether user clicked there

You can use something like this to get the index. It can be contained in a single sub-vi.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.