From 47ba6632b1be5ab7f28726735fc7789916191ca7 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 27 May 2021 08:49:12 +0200 Subject: macOS: Avoid premature FL_RELEASE event at start of drag-n-drop operation. This fixes this issue mentioned in fltk.general : https://www.fltk.org/newsgroups.php?s40623+gfltk.general+v40638+T --- src/Fl_cocoa.mm | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 15ed5fbd5..37982db02 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -556,6 +556,8 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop() #endif #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context; +- (void)draggingSession:(NSDraggingSession *)session + endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation; #endif - (BOOL)did_view_resolution_change; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 @@ -2741,6 +2743,17 @@ static FLTextInputContext* fltextinputcontext_instance = nil; { return NSDragOperationCopy; } +- (void)draggingSession:(NSDraggingSession *)session + endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation +{ + Fl_Widget *w = Fl::pushed(); + if ( w ) { + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_RELEASE); + Fl::e_number = old_event; + Fl::pushed( 0 ); + } +} #endif @end @@ -4093,14 +4106,14 @@ int Fl_Cocoa_Screen_Driver::dnd(int use_selection) [myview dragImage:image at:pt offset:offset // deprecated in 10.7 event:theEvent pasteboard:mypasteboard source:myview slideBack:YES]; + if ( w ) { + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_RELEASE); + Fl::e_number = old_event; + Fl::pushed( 0 ); + } } CFRelease(text); - if ( w ) { - int old_event = Fl::e_number; - w->handle(Fl::e_number = FL_RELEASE); - Fl::e_number = old_event; - Fl::pushed( 0 ); - } [localPool release]; return true; } -- cgit v1.2.3