Implemented file drop support in OSX
This commit is contained in:
parent
4d6d6fcbfc
commit
344a39dafd
|
@ -291,16 +291,52 @@ static int button_mask=0;
|
||||||
self = [super init];
|
self = [super init];
|
||||||
trackingArea = nil;
|
trackingArea = nil;
|
||||||
[self updateTrackingAreas];
|
[self updateTrackingAreas];
|
||||||
|
[self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void)dealloc
|
-(void)dealloc
|
||||||
{
|
{
|
||||||
[trackingArea release];
|
[trackingArea release];
|
||||||
[super dealloc];
|
[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
|
- (BOOL)isOpaque
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -833,6 +869,7 @@ static int translateKey(unsigned int key)
|
||||||
|
|
||||||
@implementation GodotWindow
|
@implementation GodotWindow
|
||||||
|
|
||||||
|
|
||||||
- (BOOL)canBecomeKeyWindow
|
- (BOOL)canBecomeKeyWindow
|
||||||
{
|
{
|
||||||
// Required for NSBorderlessWindowMask windows
|
// Required for NSBorderlessWindowMask windows
|
||||||
|
|
Loading…
Reference in New Issue