Change appearance of items that are being dragged over in treeview

Hey everyone,

Im creating an application that uses TreeView and TreeViewItem classes to represent a folder structure with files in it. I have implemented drag and drop behaviour by overriding getDragSourceDescription(), and itemDropped(). I’m using createItemComponent() to supply custom components to the treeview.

My question is: Is it possible to change the appearance of the items when they are being dragged over? Because TreeViewItem does not have virtual itemDragEnter() and itemDragExit() there does not seem to be a straighforward way. I’ve looked at Juce’s InsertPointHighlight and TargetGroupHighlight classes inside TreeView but they don’t allow for any customization either.

Treeview is not supposed to be inherited, so there is no chance of adding code to the itemDragEnter() and itemDragExit() there either. I have no idea how to approach this problem.
Thanks for your help.

change the image that gets shown. most folks use createComponentSnapshot() but you could supply some other image.

I don’t mean the image that is being dragged, but the elements of the tree that are being dragged over. The crux of the problem is that i have no way of letting these components know when they are being dragged over, because juce’s TreeViewitem doesn’t actually inherit DragAndDropTarget

maybe you’ll find some solution here: ListBox Drag-To-Reorder [Solved]

It’s not the treeview class, but it’s similar.

I think your problem is, that the TreeViewItem is actually not a component. It also confused me the first time, I saw it.

But one solution: you have the function TreeViewItem::createItemComponent(). It lets you create a component, which you can use to display your TreeViewItem. And this component can be a DragAndDropTarget and can react to things being dragged over it.