[master] 47ba663 - macOS: Avoid premature FL_RELEASE event at start of drag-n-drop operation.

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 47ba663 - macOS: Avoid premature FL_RELEASE event at start of drag-n-drop operation. "ManoloFLTK" 00:02 May 27 top right image
 
commit 47ba6632b1be5ab7f28726735fc7789916191ca7
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Thu May 27 08:49:12 2021 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Thu May 27 08:49:27 2021 +0200

     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 src/Fl_cocoa.mm src/Fl_cocoa.mm
index 15ed5fb..37982db 100644
--- src/Fl_cocoa.mm
+++ 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;
 }
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2021 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.