Here is a patch to show images for Drag and Drop operations in iOS AUv3.
Creating windows is not allowed in an app extension sandbox. So the patch tries to attach the DragImageComponent
to the top-level component if SystemStats::isRunningInAppExtensionSandbox()
returns true
and the allowDraggingToOtherJuceWindows
parameter was passed as true
.
BTW. The parameter naming is ambiguous as the parameter name implies dragging to other windows while the documentation (and code) seem to limit drag operations to the very component.
diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
index dd5633a95..67b8062ee 100644
--- a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
+++ b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
@@ -462,12 +462,25 @@ void DragAndDropContainer::startDragging (const var& sourceDescription,
if (allowDraggingToExternalWindows)
{
- if (! Desktop::canUseSemiTransparentWindows())
- dragImageComponent->setOpaque (true);
+ if (SystemStats::isRunningInAppExtensionSandbox())
+ {
+ if (auto* thisComp = dynamic_cast<Component*> (this))
+ {
+ auto topLevel = thisComp->getTopLevelComponent();
+ if (topLevel)
+ topLevel->addChildComponent (dragImageComponent);
+ }
+
+ }
+ else
+ {
+ if (! Desktop::canUseSemiTransparentWindows())
+ dragImageComponent->setOpaque (true);
- dragImageComponent->addToDesktop (ComponentPeer::windowIgnoresMouseClicks
- | ComponentPeer::windowIsTemporary
- | ComponentPeer::windowIgnoresKeyPresses);
+ dragImageComponent->addToDesktop (ComponentPeer::windowIgnoresMouseClicks
+ | ComponentPeer::windowIsTemporary
+ | ComponentPeer::windowIgnoresKeyPresses);
+ }
}
else
{