Browse Source

Linux: Fixed a DragAndDrop issue between different containers

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
a3219c7fc6
1 changed files with 22 additions and 1 deletions
  1. +22
    -1
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp

+ 22
- 1
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp 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));


Loading…
Cancel
Save