Jump to content

Tree Control -- need Dropping Between Items and Drag Over events


Recommended Posts

Hello All,

I'm trying to figure out a way to achieve something that seems a little bit tricky. In fact, the problem I'm having might be a bug. Basically, I want to use the tree control's Allow Dropping Between Item feature (a built-in drag and drop function) along with the tree's Drag Over event which allows you to programmatically enable/disable the user's ability to drop the item that they are dragging. Here is what the Allow Dropping Between Item feature looks like:

post-17-1156819605.png?width=400

The problem is that whenever I register for the Drag Over event, the Allow Dropping Between Item feature/behavior goes away.

Here is an example of the problem:

Download File:post-17-1156820022.vi

FYI - I've tested in 8.0 and 8.2 and this behavior is the same in both versions.

Thanks :-)

Link to comment

I assume that you mean that the little drag bar disappears and that items aren't inserted on drop. This is (unfortunately) expected behavior. If you register for Drag Over, Drop, or really any of the other drag and drop events on a target then the default behavior provided by LabVIEW is never executed.

I struggled with this quite a bit when I was implementing Drag and Drop as a feature in LabVIEW 8.0.... The problem is, that if you accept some datatype that the tree/listbox/string/ whatever doesn't know about, it won't know how to draw the feedback. Also, on the Drop event specifically, there is not a way currently for LabVIEW to know if you handled the event (by inserting the item) or if LabVIEW should do the insertion. Similar issues can arise if you draw your own feedback for drag drop. Therefore, the rule (for now) is that if you register for any drop target event (Drag Over, Drag Enter, or Drop) that you must implement all the drag and drop behavior yourself.

I welcome any feedback on this. This is actually a big interest of mine to revisit the drag drop events and restore some default behavior when possible or at least provide an intuitive way to mimic default behavior.

Jeff P

LabVIEW R & D

Link to comment
I assume that you mean that the little drag bar disappears and that items aren't inserted on drop. This is (unfortunately) expected behavior. If you register for Drag Over, Drop, or really any of the other drag and drop events on a target then the default behavior provided by LabVIEW is never executed.

I struggled with this quite a bit when I was implementing Drag and Drop as a feature in LabVIEW 8.0.... The problem is, that if you accept some datatype that the tree/listbox/string/ whatever doesn't know about, it won't know how to draw the feedback. Also, on the Drop event specifically, there is not a way currently for LabVIEW to know if you handled the event (by inserting the item) or if LabVIEW should do the insertion. Similar issues can arise if you draw your own feedback for drag drop. Therefore, the rule (for now) is that if you register for any drop target event (Drag Over, Drag Enter, or Drop) that you must implement all the drag and drop behavior yourself.

I welcome any feedback on this. This is actually a big interest of mine to revisit the drag drop events and restore some default behavior when possible or at least provide an intuitive way to mimic default behavior.

Jeff P

LabVIEW R & D

Jeff,

Thanks for the response. This confirms my fears. What I wonder, is how NI implements the Dropping Between Items in the Project Explorer window. Is this not implemented in G, using a Tree Control. It appears to me that the tree is monitoring the Drag event but also supports the Dropping Between Items.

As a follow-up, it would be nice if the Drag event included (filterable) data stating whether is was a Drop Between or Drop On event, or there was some way to programmatically reproduce this built-in behavior.

Thanks,

Link to comment
Jeff,

Thanks for the response. This confirms my fears. What I wonder, is how NI implements the Dropping Between Items in the Project Explorer window. Is this not implemented in G, using a Tree Control. It appears to me that the tree is monitoring the Drag event but also supports the Dropping Between Items.

As a follow-up, it would be nice if the Drag event included (filterable) data stating whether is was a Drop Between or Drop On event, or there was some way to programmatically reproduce this built-in behavior.

Thanks,

The project explorer window doesn't use a diagram to implement its behavior. It is a VI front panel that has some hooks (written in C) to customize behavior of the controls. This uses an event mechanism that more closely matches what a built in control uses rather than using an event structure. That said, I think it would be great if it were possible to write the project window in 100% G :- at least the drag drop behavior anyway.

About the "Drag" event, I assume that you actually mean the "Drop" event or one of the other target side events. I have had several suggestions stating the same thing. This actually would be more like the old type drag events for the tree. The problem is, that Drop events are defined at the control level, and Drag Between doesn't really make sense for something like a string control or graph. This doesn't necessarily mean that we couldn't make a special drop event for the tree control -- but overriding events to include specific data for a control is not something we have done generally.

At some point in the near future, I am going to write a post about how drag and drop can be improved on the LabVIEW Developer Feature Brainstorming board.

Please (both of you) feel free to register your feedback over there if you get a chance.

(I will post here when I have actually created the topic as only us internal guys are allowed to do so).

Thanks

Jeff P

Link to comment
The project explorer window doesn't use a diagram to implement its behavior. It is a VI front panel that has some hooks (written in C) to customize behavior of the controls. This uses an event mechanism that more closely matches what a built in control uses rather than using an event structure. That said, I think it would be great if it were possible to write the project window in 100% G :- at least the drag drop behavior anyway.

Gotta eat your own dog food ;) The feature gaps become obvious, quickly.

About the "Drag" event, I assume that you actually mean the "Drop" event or one of the other target side events.
Actually, it is during the Drag Over that the Drop Between visualization (horizontal line between items) is visible. I can implement a programmatic behavior that does a Drop Between, I just can't implement (in a trivial way) the horizontal line between the items as the user drags over the items. I guess I could try to float some other control (maybe a thin boolean that is fashioned to look like a horizontal line) in order to achieve this affect.

I have had several suggestions stating the same thing. This actually would be more like the old type drag events for the tree. The problem is, that Drop events are defined at the control level, and Drag Between doesn't really make sense for something like a string control or graph. This doesn't necessarily mean that we couldn't make a special drop event for the tree control -- but overriding events to include specific data for a control is not something we have done generally.

Single inheritance... it works great until it doesn't :)

At some point in the near future, I am going to write a post about how drag and drop can be improved on the LabVIEW Developer Feature Brainstorming board.

Please (both of you) feel free to register your feedback over there if you get a chance.

(I will post here when I have actually created the topic as only us internal guys are allowed to do so).

Cool. Keep us in the loop.

Thanks,

Link to comment
  • 16 years later...

Updating a very old thread:

I bumped into some of the limitations of Tree/Listbox drag/drop as discussed here.

I chose to write a G-code implementation of drag/drop behavior for Tree/Listbox controls with a few notable improvements.

Anyone who finds this thread in the future might want to take a look:

https://www.vipm.io/package/blue_origin_lib_better_drag_and_drop/

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.