diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-05-27 08:49:12 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-05-27 08:49:27 +0200 |
| commit | 47ba6632b1be5ab7f28726735fc7789916191ca7 (patch) | |
| tree | 040de6be7d1fb5034db7f36f86b695089dc1d2e7 | |
| parent | 538079c7a02ed7d64536d8425fc7dad34589488a (diff) | |
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
| -rw-r--r-- | src/Fl_cocoa.mm | 25 |
1 files 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; } |
