LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dragging items in LV7 tree control

If I have a parent item and then a group of child items and I'm dragging them within the parent group to rearrange the order, the cursor flashes back and forth back from an insertion line between two child items, to highlighting the parent item. If the parent item is out of sight because the user has scrolled down the list, the insertion line simply disappears and then should the user 'drop' the item they were dragging, it is placed out of sight at the very top of the list. Is there a way to disable this intermittent highlighting of the parent item?

It seems if you wanted to drag an item to the top of the list and highlight the parent, you would do just that and would never really want to try and perform that function by dragging o
ne item directly onto another (which, when doing a drag/drop, seems like the item would drop above or below the item the mouse was directly on).
0 Kudos
Message 1 of 3
(2,794 Views)
I am unable to replicate the selection cursor/Insertion line issue. Please include a code example if you are still having trouble. Whats your OS?
But as the tree control is currently, during a drag and drop event, whatever item is highlighted during the drop becomes it's parent.
In other words, the only way to re-order a group of siblings is by dragging and dropping them onto the parent in the correct order.
0 Kudos
Message 2 of 3
(2,794 Views)
I'm on Win2k. To reproduce the problem (the manual way)...

Create a new table
Click in the top left and type new items:

- Parent 1
- Child 1
- Child 2
- Parent 2
- Child 3
- Child 4

Drag child 1 and 2 into parent 1 so they become sub-items
Drag child 3 and 4 into parent 2 so they become sub-items

Table
- Parent 1
- Child 1
- Child 2
- Parent 2
- Child 3
- Child 4

For each child item right click and select 'Child-Only Item'

On the code page create a property node to set the attributes below:

T -> Allow Dragging
F -> Allow Dragging of Parent Items
T -> Allow Dragging Between Items

Run that once and then go back to the front panel and try dragging stuff on the tree--it will exhibit the behavior described earlier, as well as allowing you to rearrange items within a group.

I will also highlight another problem I had for my particular application... perhaps if others have it this will save some time. It took me quite a bit of banging around to find a solution.

Drag Child 3 and Child 4 into Parent 1--Parent 2 is left as an empty group.

Table
- Parent 1
- Child 1
- Child 2
- Child 3
- Child 4
- Parent 2

Now try dragging a child below parent two but not on top of it--ie, Parent 2 is not shaded but a line is visible below it indicating that is where the item will be placed. This creates what would appear to be a parent item (only it isn't).

Table
- Parent 1
- Child 1
- Child 2
- Child 3
- Parent 2
- Child 4

This surprised me, mostly because it took a while to figure out how to disable it. Filtering drop events with a little bit of logic will let you disable this behavior though.

Use the TargetTag inside the event handler with the Navigate Tree methods. If there is no parent and no child of the item you're about to drop on, and you're actually dropping BelowTarget instead of on it, then the item would normally be changed to appear as a parent on the tree.

If [Navigate Tree:Get Parent of TargetTag = Null?] AND [Navigate Tree:Get Child of TargetTag = Null?] AND [BelowTarget = True?], discard the event.

Happy putzing around. I don't think there is a way to disable the weird behavior where it flips back and forth between the parent item and the items you're in between. If you drag across several items it just flickers like crazy but at least it still works and will eventually do what you want it to... just takes some getting used to.
0 Kudos
Message 3 of 3
(2,794 Views)