(OSX) Add preliminary drag and drop code

This commit is contained in:
Twinaphex 2016-06-03 19:21:22 +02:00
parent d6d757e240
commit cbae4af38a

View File

@ -64,6 +64,7 @@ void *glkitview_init(void);
#if defined(HAVE_COCOA)
[self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSColorPboardType, NSFilenamesPboardType, nil]];
#elif defined(HAVE_COCOATOUCH)
self.view = (__bridge GLKView*)glkitview_init();
@ -96,6 +97,41 @@ void *glkitview_init(void);
{
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSDragOperation sourceDragMask = [sender draggingSourceOperationMask];
NSPasteboard *pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSFilenamesPboardType] )
{
if (sourceDragMask & NSDragOperationCopy)
return NSDragOperationCopy;
}
return NSDragOperationNone;
}
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSURLPboardType])
{
NSURL *fileURL = [NSURL URLFromPasteboard:pboard];
NSString *s = [fileURL path];
if (s != nil)
{
RARCH_LOG("Drop name is: %s\n", [s UTF8String]);
}
}
return YES;
}
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
[self setNeedsDisplay: YES];
}
#elif defined(HAVE_COCOATOUCH)
- (void)viewDidAppear:(BOOL)animated
{