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
This commit is contained in:
ManoloFLTK
2021-05-27 08:49:12 +02:00
parent 538079c7a0
commit 47ba6632b1
+19 -6
View File
@@ -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;
}