From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree Drag & Drop With Filtering: How to show Drop Between Items Line Programatically?

Greetings!

The question is:  How can I display the "drop between items" line on a tree control when I'm using Drag Over and other events to filter where items are "allowed" to be dropped.  I've attached an example VI that shows some simple code that illustrates the desired affect by underlining the tree node below which the item will be dropped.  This looks really cheesy though.  I've scoured the property and method lists and have found nothing that would allow this.

The example I posted can also be a simple primer on how to do some drag/drop filtering, so give it a peek even if you're interested in the topic but don't have any ideas for me to try.  It's a neat example. 

Thanks a bunch in advance!
0 Kudos
Message 1 of 4
(3,829 Views)
Hi Petr,

I've spent some time playing around with this, and unfortunately I could not either find a way to enable the line when event handling is enabled on a tree control. Anyhow, I appreciate you posting some illustrative code of tree controls with dragging logic.

Have a great day,
-Sam F, DAQ Marketing Manager
0 Kudos
Message 2 of 4
(3,796 Views)

I don't think that there is a built in way to do it or really any way to do it other than some trickery with an overlayed picture control or something.  I was the developer for drag and drop, and I have to admit that I know that there is room for improvement especially when trying to show feedback on customized drags.  Please, post any suggestions that you have to the forum or the suggestion center.  They will definitely not go unnoticed.

Jeff Peters

LabVIEW R & D

Message 3 of 4
(3,792 Views)

Almost ten years late to the party, but I solved the same problem last year with this scheme:

 

1... Have a single decoration, consisting of a right-facing line with arrowhead, in the pane containing the tree.

2... At startup, obtain a reference to that decoration, cache it somewhere, and make the arrow invisible.

3... At DRAG ENTER / DRAG OVER time, use the POINT TO ROW COLUMN method (invoke node) to get the tag of the item you're over.

4... Use that tag as the ACTIVE ITEM.TAG in a property node.  Obtain the INDENT LEVEL, CELL HEIGHT, and ACTIVE CELL POSITION.TOP results of that same property node.

5... Use the CELL TOP and CELL HEIGHT to divide the vertical space into four quarters.

6... Compare the Mouse COORDS.VERTICAL to the CELL TOP + the quarters.  If you're in the top quarter, then the arrow should show ABOVE the item, and be longer (horizontally wider), showing you're going to insert ABOVE.

7... If you're in the bottom quarter, the arrow should show BELOW the item, and be longer, showing you're going to insert AFTER.

8... If you're in the middle two quarters, the arrow should show ON the item center, and be shorter, showing you're going to REPLACE the item under the cursor.

 

9... Use the INDENT LEVEL to determine the width of the arrow, if you like.

10... At DROP time, do the same calculations, and then perform the insert or replace operation as indicated. 

 

11... In the DRAG ENDED event, hide the arrow decoration.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 4 of 4
(2,840 Views)