diff options
author | Juan Linietsky <reduz@Juans-MBP.fibertel.com.ar> | 2016-05-31 01:27:48 -0300 |
---|---|---|
committer | Juan Linietsky <reduz@Juans-MBP.fibertel.com.ar> | 2016-05-31 01:27:48 -0300 |
commit | 344a39dafd13922ee535928df284d4a87e8721fd (patch) | |
tree | 0094999d912528e0783d42efb58f5eb976c3cc8d /platform | |
parent | 4d6d6fcbfc9cd7e37ad38bb83c05f9260e50d5bc (diff) |
Implemented file drop support in OSX
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/os_osx.mm | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index b614dd57aa..065fe52b09 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -291,16 +291,52 @@ static int button_mask=0; self = [super init]; trackingArea = nil; [self updateTrackingAreas]; - + [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]]; return self; } + -(void)dealloc { [trackingArea release]; [super dealloc]; } +- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender { + return NSDragOperationCopy; +} + +- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender { + return NSDragOperationCopy; +} + +- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { + + + NSPasteboard *pboard = [sender draggingPasteboard]; + NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType]; + + Vector<String> files; + for(int i=0;i<filenames.count;i++) { + NSString *ns = [filenames objectAtIndex:i]; + char *utfs = strdup([ns UTF8String]); + String ret; + ret.parse_utf8(utfs); + free(utfs); + files.push_back(ret); + + + } + + if (files.size()) { + OS_OSX::singleton->main_loop->drop_files(files,0); + OS_OSX::singleton->move_window_to_foreground(); + } + + return NO; +} + + - (BOOL)isOpaque { return YES; @@ -833,6 +869,7 @@ static int translateKey(unsigned int key) @implementation GodotWindow + - (BOOL)canBecomeKeyWindow { // Required for NSBorderlessWindowMask windows |