-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDragAndDropOutlineView.m
47 lines (38 loc) · 1.05 KB
/
DragAndDropOutlineView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// DragAndDropOutlineView.m
// GPSLogger
//
// Created by German Laullon on 17/11/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import "DragAndDropOutlineView.h"
#import "SideBarDataSource.h"
@implementation DragAndDropOutlineView
-(void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
}
- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender
{
return NSDragOperationCopy;
}
- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
{
return NSDragOperationCopy;
}
- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender
{
return YES;
}
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender
{
NSMutableArray *files = [NSMutableArray array];
for(NSPasteboardItem *item in [[sender draggingPasteboard] pasteboardItems]){
NSURL *url = [NSURL URLWithString:[item stringForType:@"public.file-url"]];
[files addObject:url];
}
SideBarDataSource *ds = self.dataSource;
[ds readFiles:files];
return YES;
}
@end