LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event handler elements inside of the array

I have an array of clusters, of which inside the cluster are buttons.   I want to be able to tie an event handler to these buttons ( they would all handle the event the same, the only difference would be the index they were handling) 

 

A while back a similiar problem was posted here:

 

http://forums.ni.com/t5/LabVIEW/Array-of-Clusters-with-Graph-Y-Scale-Change-Event/td-p/1194181/page/...

 

However, this solution did not appear to be able to deliver the index of which button in the array was pressed .. this is critical for my application.   The button is basically an "edit' buttonw which allows the user to edit the elements of the cluster through a popup.   Obviously I need to know which cluster the user intends to edit.

0 Kudos
Message 1 of 5
(2,931 Views)

One option: when the code starts, build an array of references to the edit buttons inside each cluster. Then, in the event case, search that array for the reference that triggered the event. The index at which the reference is found tells you which cluster to edit.

Message 2 of 5
(2,922 Views)

@nathand wrote:

One option: when the code starts, build an array of references to the edit buttons inside each cluster. Then, in the event case, search that array for the reference that triggered the event. The index at which the reference is found tells you which cluster to edit.


This might work, but it should be possible for the user to add/delete elements from the array so I would need to be able to do this even after program initialization.

 

Currently, I have just made dozen buttons alongside the array of clusters.  But this workaround won't allow past a fixed number at program initialization.

0 Kudos
Message 3 of 5
(2,910 Views)

I'm sorry, I misunderstood what you're trying to do. I thought you had several independent clusters, I didn't realize they're all in an array. I should have read more carefully.

 

Personally what I would do is register for a value change event on the entire array. Then you can quickly go through the whole array looking for an element in which the Edit button is True. Alternatively you could do this by reading the array's terminal and looping through that, while registering only for events on the Edit button.

0 Kudos
Message 4 of 5
(2,905 Views)

Here's a snippet showing what I described in the previous post.

clicked button in cluster array.png

Message 5 of 5
(2,901 Views)