DragAndDropTarget::shouldDrawDragImageWhenOver() isn't working as expected


#1

Hi,

I have a parent component with some draggable elements. When I start to drag an element, I don't want it to show any image underneath the cursor until it is outside from that parent component. So, I tried two approaches:

1. Redefining DragAndDropTarget::shouldDrawDragImageWhenOver() to return false. The momment I start the drag operation, the image is shown while I do the first move, then it rapidly dissapears (buggy behaviour?). Can this be fixed? Have you any ideas?

2. Using differents calls to DragAndDropContainer::startDragging() with different images. But once you start with the dragging operation it creates a Component (dragImageComponent) that cannot be deleted until the drag operation ends. Then the different calls to startDragging() haven't any effect. Is there a way to delete manually this Component?


#2

I would have thought the obvious answer would be to not call startDragging until the mouse cursor has reached a point where you want to it happen.


#3

Thank you, that did the trick without hacking the class. However, if you find the time, I think it should be a good idea if you can fix the shouldDrawDragImageWhenOver() working.


#4

Sorry, I didn't notice what you said about it appearing and disappearing.. Yes, looks like a bugette - presumably it'll work better if I remove line 429 of juce_DragAndDropContainer.cpp, which looks like it's unnecessarily making the component visible.

(It probably still makes sense to only begin the drag operation when the mouse moves out of your component though, if that's the intended behaviour)