[3.2] Fix file drag-drop on M1 Macs.
This commit is contained in:
parent
40333a02de
commit
36a6a713b4
1 changed files with 16 additions and 12 deletions
|
@ -638,26 +638,30 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
|
|
||||||
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
|
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
|
||||||
|
|
||||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
|
|
||||||
NSArray<NSURL *> *filenames = [pboard propertyListForType:NSPasteboardTypeFileURL];
|
|
||||||
#else
|
|
||||||
NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Vector<String> files;
|
Vector<String> files;
|
||||||
for (NSUInteger i = 0; i < filenames.count; i++) {
|
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
|
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
|
||||||
NSString *ns = [[filenames objectAtIndex:i] path];
|
NSArray *items = pboard.pasteboardItems;
|
||||||
#else
|
for (NSPasteboardItem *item in items) {
|
||||||
NSString *ns = [filenames objectAtIndex:i];
|
NSString *path = [item stringForType:NSPasteboardTypeFileURL];
|
||||||
#endif
|
NSString *ns = [NSURL URLWithString:path].path;
|
||||||
char *utfs = strdup([ns UTF8String]);
|
char *utfs = strdup([ns UTF8String]);
|
||||||
String ret;
|
String ret;
|
||||||
ret.parse_utf8(utfs);
|
ret.parse_utf8(utfs);
|
||||||
free(utfs);
|
free(utfs);
|
||||||
files.push_back(ret);
|
files.push_back(ret);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
|
||||||
|
for (NSString *ns in filenames) {
|
||||||
|
char *utfs = strdup([ns UTF8String]);
|
||||||
|
String ret;
|
||||||
|
ret.parse_utf8(utfs);
|
||||||
|
free(utfs);
|
||||||
|
files.push_back(ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (files.size()) {
|
if (files.size()) {
|
||||||
OS_OSX::singleton->main_loop->drop_files(files, 0);
|
OS_OSX::singleton->main_loop->drop_files(files, 0);
|
||||||
|
|
Loading…
Reference in a new issue