Jump to content

Tree control drag/drop event woes


Recommended Posts

I have a tree control that represents a bunch of data from a database. A user must be able to logically re-arrange that data using drag and drop. I therefore want to catch the drag / drop events to determine:

1. During the drag, is the current potential drop location valid?

2. At the end of the drag, was the database update successful? (if not, I want to discard the drag/drop action).

I seem to be running into a big headache with the necessary tree control filter events in that:

A. Adding a drag over event seems to be discardign the drag/drop action

B. The drop filter event seems to be causing nodes to vanish.

:frusty:

I have made a slimmed down VI (ie with everything but the tree control removed), and made two tree controls (one with the drag over event, and one without) to demonstrate the problem. I would really appreciate any ideas as to what is going wrong! (LV 2009)

Thanks!

Shaun

(I have also put in a support request to NI, so if they come up with a solution, I'll be sure to post back!)

Debug - Drag and Drop Test.vi

Link to comment

OK it looks like I've found a hack work around to the LV 2009 tree control drag/drop events: copy and paste a tree control and it's associated event structure (including "Drag?" and "Drop?" filter events from an application written in an earlier version of LabVIEW -> these *seem* to work, but as it's dinner time, I'll have to wait until tomorrow to give it some proper testing.

PS> If any one else goes down this route, remember that if those "Drag?" and "Drop?" filter events are deleted they cannot be recreated in LV 2009!

Link to comment

Thanks Ton - It seems that you are right, if I put in all of the drag and drop code manually with all of the events I might be able to get it to work with the non-legacy event structures.... However, I dont suppose you (or anyone else for that matter) know(s) if there is a way to get the visual feedback (or even something similar to) that one gets with the built-in drag/drop handling?

Link to comment

I have the following construct:

A 'Drop' event on a tree control.

In this event I have set 'accepted' to 'False', this means that LabVIEW assumes that the drop was unsuccesfull.

No problem. I handle the drop of data inside that event myself.

A 'drag ended' event on the same tree control.

This is triggered when the drag has ended (whether the drag and drop was succesfull or not). I use this to rearrange my data structure.

Here is the drop event code:

post-2399-126349966841_thumb.png

PS the equal tests the 'parent' output of the following subVI.

And here is the code of the subvi:

post-2399-12634997678_thumb.png

Ton

  • Like 2
Link to comment

Wow - thanks Tom! There's definately a lot there for me to chew over (and come up with some ideas)!

Unfortunately, due to time / $$ constraints and the fact that I'm creating a new app that is going to be an upgrade to a very old and bloated LV 7 (if not earlier) app, I think for now I am going to have to stick with the depreciated events as they are so much easier to get the right look and feel.

Still... next time I get a spare movement, I'm going to definitely have to look into this some more! :)

Link to comment
  • 6 months later...

These are two separate issues: drag over not working, and drop deleting tree items. You can use the attached VI to copy a tree and event structure out of. What's important is that you have the old event ("Drop?", not "Drop"). You can replace the tree with a system tree as long as you right click on the tree and select Replace. Don't delete the tree.

TreeWithDropEvent.vi

Link to comment
  • 4 months later...

These are two separate issues: drag over not working, and drop deleting tree items.  You can use the attached VI to copy a tree and event structure out of.  What's important is that you have the old event ("Drop?", not "Drop").  You can replace the tree with a system tree as long as you right click on the tree and select Replace.  Don't delete the tree.

Hi! 

Is there any way to Get these new Items, without replacing my old event structure with yours? My App is big...

Link to comment
  • 2 months later...

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.