| @@ -243,13 +243,34 @@ private: | |||||
| return dynamic_cast<DragAndDropTarget*> (currentlyOverComp.get()); | 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, | DragAndDropTarget* findTarget (Point<int> screenPos, Point<int>& relativePos, | ||||
| Component*& resultComponent) const | Component*& resultComponent) const | ||||
| { | { | ||||
| auto* hit = getParentComponent(); | auto* hit = getParentComponent(); | ||||
| if (hit == nullptr) | if (hit == nullptr) | ||||
| hit = Desktop::getInstance().findComponentAt (screenPos); | |||||
| hit = findDesktopComponentBelow (screenPos); | |||||
| else | else | ||||
| hit = hit->getComponentAt (hit->getLocalPoint (nullptr, screenPos)); | hit = hit->getComponentAt (hit->getLocalPoint (nullptr, screenPos)); | ||||