View Single Post
Old 06-29-2021, 07:37 AM   #20
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 70
Default

Thanks, it's finally working:

I modified the file IGraphicsCocoa.mm

In initWithIGraphics: (IGraphicsMac*) pGraphics added:
Code:
[self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
then
Code:
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>) sender {
    NSPasteboard *pboard = [sender draggingPasteboard]; 
    return (([pboard.types containsObject:NSFilenamesPboardType]) ? NSDragOperationLink : NSDragOperationNone);
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>) sender {
    NSPasteboard *pboard = [sender draggingPasteboard];
    if ( [[pboard types] containsObject:NSFilenamesPboardType] ) { 
      NSPoint pt = [self convertPoint:[sender draggingLocation] fromView:nil]; 
      for (NSString *path in [pboard propertyListForType:NSFilenamesPboardType]) {
        const char* tmp=[path UTF8String];
        if (mGraphics)  {
          mGraphics->OnMouseDragDrop(pt.x, mGraphics->Height() - pt.y, (char*)tmp);
          break;
        }
      }
    }
    return YES;
}
Two questions:

How can I limit dragging on two types of files: wav and aif

This code also works on new versions of macOS, from Sierra above?
TonyGlover is offline   Reply With Quote