Browse Source

macOS: Generate a missing mouse up when DragAndDropContainer drag event ends

tags/2021-05-28
ed 7 years ago
parent
commit
2fd19af539
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      modules/juce_gui_basics/native/juce_mac_Windowing.mm

+ 9
- 2
modules/juce_gui_basics/native/juce_mac_Windowing.mm View File

@@ -167,7 +167,7 @@ static NSRect getDragRect (NSView* view, NSEvent* event)
static NSView* getNSViewForDragEvent (Component* sourceComp) static NSView* getNSViewForDragEvent (Component* sourceComp)
{ {
if (sourceComp == nullptr) if (sourceComp == nullptr)
if (auto* draggingSource = Desktop::getInstance().getDraggingMouseSource(0))
if (auto* draggingSource = Desktop::getInstance().getDraggingMouseSource (0))
sourceComp = draggingSource->getComponentUnderMouse(); sourceComp = draggingSource->getComponentUnderMouse();
if (sourceComp != nullptr) if (sourceComp != nullptr)
@@ -234,8 +234,15 @@ private:
return *getIvar<NSDragOperation*> (self, "operation"); return *getIvar<NSDragOperation*> (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<std::function<void()>*> (self, "callback")) if (auto* cb = getIvar<std::function<void()>*> (self, "callback"))
cb->operator()(); cb->operator()();
} }


Loading…
Cancel
Save