Cocoa: support drag-and-drop of multiple objects.
This commit is contained in:
parent
b5c43a88b4
commit
65a1a3e7e9
@ -106,18 +106,35 @@
|
|||||||
|
|
||||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
|
if (([sender draggingSourceOperationMask] & NSDragOperationGeneric) == NSDragOperationGeneric) {
|
||||||
return NSDragOperationGeneric;
|
return NSDragOperationGeneric;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
return NSDragOperationNone; /* no idea what to do with this, reject it. */
|
||||||
{
|
}
|
||||||
NSURL *fileURL = [NSURL URLFromPasteboard:[sender draggingPasteboard]];
|
|
||||||
NSNumber *isAlias = nil;
|
|
||||||
|
|
||||||
if (fileURL == nil) {
|
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||||
|
{ @autoreleasepool
|
||||||
|
{
|
||||||
|
NSPasteboard *pasteboard = [sender draggingPasteboard];
|
||||||
|
NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType];
|
||||||
|
NSString *desiredType = [pasteboard availableTypeFromArray:types];
|
||||||
|
if (desiredType == nil) {
|
||||||
|
return NO; /* can't accept anything that's being dropped here. */
|
||||||
|
}
|
||||||
|
|
||||||
|
NSData *data = [pasteboard dataForType:desiredType];
|
||||||
|
if (data == nil) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]);
|
||||||
|
NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
|
||||||
|
|
||||||
|
for (NSString *path in array) {
|
||||||
|
NSURL *fileURL = [[NSURL fileURLWithPath:path] autorelease];
|
||||||
|
NSNumber *isAlias = nil;
|
||||||
|
|
||||||
/* Functionality for resolving URL aliases was added with OS X 10.6. */
|
/* Functionality for resolving URL aliases was added with OS X 10.6. */
|
||||||
if ([fileURL respondsToSelector:@selector(getResourceValue:forKey:error:)]) {
|
if ([fileURL respondsToSelector:@selector(getResourceValue:forKey:error:)]) {
|
||||||
[fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
|
[fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
|
||||||
@ -140,8 +157,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (BOOL) SDL_SendDropFile([[fileURL path] UTF8String]);
|
if (!SDL_SendDropFile([[fileURL path] UTF8String])) {
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}}
|
||||||
|
|
||||||
- (BOOL)wantsPeriodicDraggingUpdates
|
- (BOOL)wantsPeriodicDraggingUpdates
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user