Skip to content

Commit a48678d

Browse files
author
徐扬斌
committed
wxOSX: Relax DoDragDrop() constraints.
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.
1 parent 1167349 commit a48678d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/osx/cocoa/dnd.mm

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,21 @@ - (nullable id)pasteboardPropertyListForType:(nonnull NSPasteboardType)type
522522
if (view)
523523
{
524524
NSEvent* theEvent = (NSEvent*)wxTheApp->MacGetCurrentEvent();
525-
wxASSERT_MSG(theEvent, "DoDragDrop must be called in response to a mouse down or drag event.");
526-
525+
// relax the constraint set for DoDragDrop().
526+
// if the user start DnD something from a frame rendered by CEF or similar framework, it should be perfectly valid.
527+
if (theEvent == nil){
528+
NSPoint mouse_location = [NSEvent mouseLocation];
529+
theEvent = [NSEvent mouseEventWithType:NSEventTypeLeftMouseDragged
530+
location:mouse_location
531+
modifierFlags:0
532+
timestamp: 0
533+
windowNumber: [NSWindow windowNumberAtPoint:mouse_location belowWindowWithWindowNumber:0]
534+
context:nil
535+
eventNumber: 0
536+
clickCount: 0
537+
pressure: 1.0];
538+
}
539+
527540
gCurrentSource = this;
528541

529542
DropSourceDelegate* delegate = [[DropSourceDelegate alloc] init];

0 commit comments

Comments
 (0)