Override application:openFiles: instead of application:openFile:

This commit is contained in:
David Capello 2016-04-11 17:27:34 -03:00
parent 49f11648b3
commit 5ef931b7d4
2 changed files with 8 additions and 3 deletions

View File

@ -14,7 +14,7 @@
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender;
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)app;
- (void)applicationWillTerminate:(NSNotification*)notification;
- (BOOL)application:(NSApplication*)app openFile:(NSString*)filename;
- (BOOL)application:(NSApplication*)app openFiles:(NSArray*)filenames;
@end
#endif

View File

@ -36,15 +36,20 @@
she::queue_event(ev);
}
- (BOOL)application:(NSApplication*)app openFile:(NSString*)filename
- (BOOL)application:(NSApplication*)app openFiles:(NSArray*)filenames
{
std::vector<std::string> files;
files.push_back([filename UTF8String]);
for (int i=0; i<[filenames count]; ++i) {
NSString* fn = [filenames objectAtIndex: i];
files.push_back([fn UTF8String]);
}
she::Event ev;
ev.setType(she::Event::DropFiles);
ev.setFiles(files);
she::queue_event(ev);
[app replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
return YES;
}