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

Linux: Fixed a DragAndDrop issue between different containers

This commit is contained in:
Tom Poole 2018-08-21 19:20:03 +01:00
parent 3638995f8b
commit a3219c7fc6

View file

@ -243,13 +243,34 @@ 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 dPoint = desktopComponent->getLocalPoint (nullptr, screenPos);
if (auto* c = desktopComponent->getComponentAt (dPoint))
{
auto cPoint = c->getLocalPoint (desktopComponent, dPoint);
if (c->hitTest (cPoint.getX(), cPoint.getY()))
return c;
}
}
return nullptr;
}
DragAndDropTarget* findTarget (Point<int> screenPos, Point<int>& relativePos,
Component*& resultComponent) const
{
auto* hit = getParentComponent();
if (hit == nullptr)
hit = Desktop::getInstance().findComponentAt (screenPos);
hit = findDesktopComponentBelow (screenPos);
else
hit = hit->getComponentAt (hit->getLocalPoint (nullptr, screenPos));