diff options
author | Nyx0uf <benjgodard@me.com> | 2014-01-09 14:42:43 +0100 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2014-01-10 10:48:54 +0100 |
commit | 0f8558a72379338d615b9526b57e5185e6ed0665 (patch) | |
tree | 3caa1edb8033897f6af199be9e504a5e5bc5f8d0 /video/out/cocoa | |
parent | b6907a7bb547750db73d3036ef9a260fbc6d0e65 (diff) | |
download | mpv-0f8558a72379338d615b9526b57e5185e6ed0665.tar.bz2 mpv-0f8558a72379338d615b9526b57e5185e6ed0665.tar.xz |
cocoa: allow to drag and drop URLs
This commit also improves the visual feedback to the user by showing a plus
icon in the mouse cursor when dragging supported types.
Fixes #469
Diffstat (limited to 'video/out/cocoa')
-rw-r--r-- | video/out/cocoa/view.m | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/video/out/cocoa/view.m b/video/out/cocoa/view.m index 9fc7506fc6..f5b69a7fbc 100644 --- a/video/out/cocoa/view.m +++ b/video/out/cocoa/view.m @@ -33,7 +33,8 @@ - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { - [self registerForDraggedTypes:@[NSFilenamesPboardType]]; + [self registerForDraggedTypes:@[NSFilenamesPboardType, + NSURLPboardType]]; } return self; } @@ -234,14 +235,27 @@ - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender { - return NSDragOperationEvery; + NSPasteboard *pboard = [sender draggingPasteboard]; + NSArray *types = [pboard types]; + if ([types containsObject:NSFilenamesPboardType] || + [types containsObject:NSURLPboardType]) + return NSDragOperationCopy; + else + return NSDragOperationNone; } - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender { NSPasteboard *pboard = [sender draggingPasteboard]; - NSArray *pbitems = [pboard propertyListForType:NSFilenamesPboardType]; - [self.adapter handleFilesArray:pbitems]; - return YES; + if ([[pboard types] containsObject:NSURLPboardType]) { + NSURL *file_url = [NSURL URLFromPasteboard:pboard]; + [self.adapter handleFilesArray:@[[file_url absoluteString]]]; + return YES; + } else if ([[pboard types] containsObject:NSFilenamesPboardType]) { + NSArray *pbitems = [pboard propertyListForType:NSFilenamesPboardType]; + [self.adapter handleFilesArray:pbitems]; + return YES; + } + return NO; } @end |