diff --git a/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/modules/juce_gui_basics/native/juce_mac_Windowing.mm index 05cddd8478..53146b90d0 100644 --- a/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -167,7 +167,7 @@ static NSRect getDragRect (NSView* view, NSEvent* event) static NSView* getNSViewForDragEvent (Component* sourceComp) { if (sourceComp == nullptr) - if (auto* draggingSource = Desktop::getInstance().getDraggingMouseSource(0)) + if (auto* draggingSource = Desktop::getInstance().getDraggingMouseSource (0)) sourceComp = draggingSource->getComponentUnderMouse(); if (sourceComp != nullptr) @@ -234,8 +234,15 @@ private: return *getIvar (self, "operation"); } - static void draggingSessionEnded (id self, SEL, NSDraggingSession*, NSPoint, NSDragOperation) + static void draggingSessionEnded (id self, SEL, NSDraggingSession*, NSPoint p, NSDragOperation) { + // Our view doesn't receive a mouse up when the drag ends so we need to generate one here and send it... + if (auto* view = getNSViewForDragEvent (nullptr)) + { + auto* cgEvent = CGEventCreateMouseEvent (nullptr, kCGEventLeftMouseUp, p, kCGMouseButtonLeft); + [view mouseUp: [NSEvent eventWithCGEvent:cgEvent]]; + } + if (auto* cb = getIvar*> (self, "callback")) cb->operator()(); }