LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I get drag target from drag source event?

Solved!
Go to solution

I am adding drag and drop functionality from a tree control on one VI to many drag targets all on different VI's.  For instance, they can drag from the tree to an XY graph on another VI, a table on another VI, a numeric indicator on another VI, etc...  Furthermore, when they drop the data, I need to know where they dropped it and initiate some action from the drag source (tree control) VI.

 

My problem is, I can't see any way to determine which VI and control the drop action occurred on.  I'm basically looking for the control reference to the drag and drop target after the drop event occurs.

 

I know that I have to add some event cases to all the various targets, but I'm trying to keep the code minimal and keep most of the complexity in the VI with the source.  If I am forced to, I'll use some sort of a global or action engine to write an identifier from the target VI to a place where the source VI can read it, but I'd rather not do that in many places if I don't have to.

0 Kudos
Message 1 of 2
(2,393 Views)
Solution
Accepted by Thomas_robertson

Create your own User Event of type "Control" and register it in the same diagram as the source Tree. On the "Drag Starting?" filter event from the source tree, inject this User Event Ref into the Drag Data (it will need to be flattened). Then, in the "Drop" event handler, unflatten that User Event Ref and Send User Event with the value from the "Ref" event data from that "Drop" event handler. This is a form of a callback function, which is much more reliable than a global or action engine that exposes the risk of race conditions.

0 Kudos
Message 2 of 2
(2,372 Views)