The documentation of DragAndDropTarget::SourceDetails states that localPosition may be null for calls such as isInterestedInDragSource(). Unfortunately this is exactly where this information is needed.
Components with a lot of graphical details use local hit detection to determine the anticipated drop action. For example, you probably don’t want to create a nested juce::Component for every note head on a staff in a notation app. The notation component will rather look for the note under the mouse and respond to isInterestedInDragSource() accordingly (e.g. expecting to drop a color swatch on the note head).
Fortunately the fix is trivial:
juce_DragAndDropContainer.cpp, line 314, ff
while (hit != nullptr)
{
if (auto* ddt = dynamic_cast<DragAndDropTarget*> (hit))
{
auto p = hit->getLocalPoint (nullptr, screenPos);
details.localPosition = p;
if (ddt->isInterestedInDragSource (details))
return std::tuple (ddt, hit, p);
}
hit = hit->getParentComponent();
}
The function findTarget() operates on a copy of SourceDetails anyway, so setting localPosition immediately before calling isInterestedInDragSource() does the trick.
Please consider this fix for integration. Thank you.
