Skip to content

Commit

Permalink
wxOSX: Relax DoDragDrop() constraints.
Browse files Browse the repository at this point in the history
DoDragDrop() not assert 'It must be called in response to a mouse down or drag event.'.
But when the user start DnD something from a frame rendered by CEF or similar framework,
it should be perfectly valid.
  • Loading branch information
徐扬斌 committed Apr 30, 2024
1 parent 6f4f244 commit 71bf9d8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/osx/cocoa/dnd.mm
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,21 @@ - (nullable id)pasteboardPropertyListForType:(nonnull NSPasteboardType)type
if (view)
{
NSEvent* theEvent = (NSEvent*)wxTheApp->MacGetCurrentEvent();
wxASSERT_MSG(theEvent, "DoDragDrop must be called in response to a mouse down or drag event.");

// relax the constraint set for DoDragDrop().
// if the user start DnD something from a frame rendered by CEF or similar framework, it should be perfectly valid.
if (theEvent == nil){
NSPoint mouse_location = [NSEvent mouseLocation];
theEvent = [NSEvent mouseEventWithType:NSEventTypeLeftMouseDragged
location:mouse_location
modifierFlags:0
timestamp: 0
windowNumber: [NSWindow windowNumberAtPoint:mouse_location belowWindowWithWindowNumber:0]
context:nil
eventNumber: 0
clickCount: 0
pressure: 1.0];
}

gCurrentSource = this;

DropSourceDelegate* delegate = [[DropSourceDelegate alloc] init];
Expand Down

0 comments on commit 71bf9d8

Please sign in to comment.