1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed a bug when performing a DragAndDrop across windows

This commit is contained in:
Tom Poole 2018-08-21 11:29:06 +01:00
parent b8b25ac487
commit e763ac3de2

View file

@ -243,30 +243,13 @@ private:
return dynamic_cast<DragAndDropTarget*> (currentlyOverComp.get());
}
static Component* findDesktopComponentBelow (Point<int> screenPos)
{
auto& desktop = Desktop::getInstance();
for (auto i = desktop.getNumComponents(); --i >= 0;)
{
auto* desktopComponent = desktop.getComponent (i);
auto localPoint = desktopComponent->getLocalPoint (nullptr, screenPos);
if (auto* c = desktopComponent->getComponentAt (localPoint))
if (c->hitTest (localPoint.getX(), localPoint.getY()))
return c;
}
return nullptr;
}
DragAndDropTarget* findTarget (Point<int> screenPos, Point<int>& relativePos,
Component*& resultComponent) const
{
auto* hit = getParentComponent();
if (hit == nullptr)
hit = findDesktopComponentBelow (screenPos);
hit = Desktop::getInstance().findComponentAt (screenPos);
else
hit = hit->getComponentAt (hit->getLocalPoint (nullptr, screenPos));