mirror of https://github.com/mpv-player/mpv
cocoa: fix dropping of files and URLs
the problem here is that dropped files can also be treated as NSURLPboardType instead of just NSFilenamesPboardType. the 'else if' could never be reached and was dead code. this basically revertsed695ce
which tried to fix multiple dropped URLs, or rather files, and moves the filename check infront of the URL check. the filename path can handle multiple dropped files, whereas the URL path can only handle one dropped URL. this assumes that only one URL can be dropped at a time. it also revertsa603543
because it's not needed any more. this also fixes a problem where dropped URLs from Chrome don't conform to the NSURL class and the readObjectsForClasses method always returned an empty URL. Fixes #4036
This commit is contained in:
parent
6da224b1dd
commit
5f10a415d7
|
@ -313,23 +313,14 @@
|
|||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||
if ([[pboard types] containsObject:NSURLPboardType]) {
|
||||
NSArray *pbitems = [pboard readObjectsForClasses:@[[NSURL class]]
|
||||
options:@{}];
|
||||
NSMutableArray* ar = [[[NSMutableArray alloc] init] autorelease];
|
||||
for (NSURL* url in pbitems) {
|
||||
if ([url isFileURL]) {
|
||||
[ar addObject:[url path]];
|
||||
} else {
|
||||
[ar addObject:[url absoluteString]];
|
||||
}
|
||||
}
|
||||
[self.adapter handleFilesArray:ar];
|
||||
return YES;
|
||||
} else if ([[pboard types] containsObject:NSFilenamesPboardType]) {
|
||||
if ([[pboard types] containsObject:NSFilenamesPboardType]) {
|
||||
NSArray *pbitems = [pboard propertyListForType:NSFilenamesPboardType];
|
||||
[self.adapter handleFilesArray:pbitems];
|
||||
return YES;
|
||||
} else if ([[pboard types] containsObject:NSURLPboardType]) {
|
||||
NSURL *url = [NSURL URLFromPasteboard:pboard];
|
||||
[self.adapter handleFilesArray:@[[url absoluteString]]];
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue