mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
macOS: Generate a missing mouse up when DragAndDropContainer drag event ends
This commit is contained in:
parent
9dde83e662
commit
2fd19af539
1 changed files with 9 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue