| 63 | } |
| 64 | |
| 65 | bool MacFileSystem::ShowOpenFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array<String>& filenames) |
| 66 | { |
| 67 | bool result = true; |
| 68 | @autoreleasepool { |
| 69 | NSWindow* focusedWindow = [[NSApplication sharedApplication] keyWindow]; |
| 70 | |
| 71 | NSOpenPanel* dialog = [NSOpenPanel openPanel]; |
| 72 | [dialog setCanChooseFiles:YES]; |
| 73 | [dialog setCanChooseDirectories:NO]; |
| 74 | [dialog setAllowsMultipleSelection:multiSelect ? YES : NO]; |
| 75 | InitMacDialog(dialog, initialDirectory, filter, title); |
| 76 | |
| 77 | if ([dialog runModal] == NSModalResponseOK) |
| 78 | { |
| 79 | if (multiSelect) |
| 80 | { |
| 81 | const NSArray* urls = [dialog URLs]; |
| 82 | for (int32 i = 0; i < [urls count]; i++) |
| 83 | filenames.Add(AppleUtils::ToString((CFStringRef)[[urls objectAtIndex:i] path])); |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | const NSURL* url = [dialog URL]; |
| 88 | filenames.Add(AppleUtils::ToString((CFStringRef)[url path])); |
| 89 | } |
| 90 | result = false; |
| 91 | } |
| 92 | |
| 93 | [focusedWindow makeKeyAndOrderFront:nil]; |
| 94 | } |
| 95 | return result; |
| 96 | } |
| 97 |
no test coverage detected