-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFileDrop.mm
More file actions
42 lines (32 loc) · 807 Bytes
/
FileDrop.mm
File metadata and controls
42 lines (32 loc) · 807 Bytes
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
#include <Foundation/NSObject.h>
#include <Foundation/NSString.h>
#include <Foundation/NSArray.h>
#include <AppKit/NSApplication.h>
#include <SDL/SDL.h>
#include <string>
@interface SDLMain : NSObject <NSApplicationDelegate>
@end
@interface FileDrop : SDLMain
- (id)init;
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
@end
@implementation FileDrop : SDLMain
- (id)init
{
self = [super init];
return self;
}
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
SDL_Event event = {0};
event.type = SDL_USEREVENT;
event.user.data1 = new std::string([filename UTF8String]);
SDL_PushEvent( &event );
return TRUE;
}
@end
void FileDropEnable( void )
{
[[NSApp delegate] release];
[NSApp setDelegate:[[FileDrop alloc] init]];
}