[branch-1.3] 40031b6 - macOS: Avoid premature FL_RELEASE event at start of drag-n-drop operation.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[branch-1.3] 40031b6 - macOS: Avoid premature FL_RELEASE event at start of drag-n-drop operation. "ManoloFLTK" May 26, 2021 top right image
 
commit 40031b67f69997db702bb84e8373d5f4ab958b3c
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Thu May 27 08:11:25 2021 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Thu May 27 08:11:25 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 | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git src/Fl_cocoa.mm src/Fl_cocoa.mm
index c9ee7d7..fd2c50b 100644
--- src/Fl_cocoa.mm
+++ src/Fl_cocoa.mm
@@ -2700,6 +2700,17 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
   }
   fl_unlock_function();
 }
+- (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 );
+  }
+}
 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
 {
   return NSDragOperationGeneric;
@@ -4342,14 +4353,14 @@ int Fl_X::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-2023 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.