Browse Source

mac: rewrite file dialog without a for-each loop

pull/161/head
JP Cimalando 6 years ago
parent
commit
94b945d8f4
1 changed files with 11 additions and 5 deletions
  1. +11
    -5
      dgl/src/Window.cpp

+ 11
- 5
dgl/src/Window.cpp View File

@@ -1387,18 +1387,24 @@ bool Window::openFileBrowser(const FileBrowserOptions& options)
{
if (result == NSFileHandlingPanelOKButton)
{
for (NSURL* url in [panel URLs])
NSArray *urls = [panel URLs];
NSURL *fileUrl = nullptr;

for (NSUInteger i = 0, n = [urls count]; i < n && !fileUrl; ++i)
{
if (![url isFileURL])
continue;
NSURL *url = (NSURL *)[urls objectAtIndex:i];
if ([url isFileURL])
fileUrl = url;
}

if (fileUrl)
{
PuglView *view = pData->fView;
if (view->fileSelectedFunc)
{
const char* fileName = [url.path UTF8String];
const char* fileName = [fileUrl.path UTF8String];
view->fileSelectedFunc(view, fileName);
}
break;
}
}



Loading…
Cancel
Save