I am trying to use NSOpenPanel to retrieve URL of the location to save a file , but the dialog never closes. This was working just fine on OSX 10.10 but not on 10.11.
Are there any changes that caused this or is it something that i am doing wrong? Here is the piece of code:-
string
FileSystemUtil::OpenFolderImpl(const std::string& initDir)
{
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setFloatingPanel: YES];
[openDlg setCanChooseFiles:NO];
[openDlg setCanChooseDirectories:YES];
[openDlg setResolvesAliases:NO];
[openDlg setAllowsMultipleSelection:NO];
if (!initDir.empty()) {
NSString *path = [NSString stringWithCString:initDir.c_str()
encoding:[NSString defaultCStringEncoding]];
NSURL *urlPath = [NSURL fileURLWithPath:path];
[openDlg setDirectoryURL:urlPath];
}
if ( [openDlg runModal] == NSOKButton ) {
NSURL *url = [openDlg URL];
NSString *filename = [url path];
return string([filename UTF8String]);
}
return "";
}
PS- the function returns the correct URL, but the dialog window still remains open.