Skip to content

Instantly share code, notes, and snippets.

@jhoughjr
Created December 26, 2014 18:44
Show Gist options
  • Save jhoughjr/d68fe265c74706ecc01b to your computer and use it in GitHub Desktop.
Save jhoughjr/d68fe265c74706ecc01b to your computer and use it in GitHub Desktop.
- (void)mouseDown:(NSEvent *)theEvent
{
DLog(@"");
// Write data to the pasteboard
NSArray *fileList = @[[NSString stringWithFormat:@"%@://%@", self.url.scheme, self.url.path]];
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObject:NSTIFFPboardType]
owner:nil];
[pboard setPropertyList:fileList
forType:NSFilenamesPboardType];
NSDraggingItem *item = [[NSDraggingItem alloc] initWithPasteboardWriter:self];
[item setImageComponentsProvider:^NSArray *{
NSDraggingImageComponent *imageComponent = [[NSDraggingImageComponent alloc] initWithKey:NSDraggingImageComponentIconKey];
imageComponent.contents = self.memeImageView.image;
return @[imageComponent];
}];
[self beginDraggingSessionWithItems:@[item]
event:theEvent
source:self];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment