Files
biomed/GUIDialogs.mm
2026-02-12 10:51:02 +01:00

30 lines
696 B
Plaintext

#include "GUIDialogs.h"
#import <AppKit/AppKit.h>
namespace GUIDialogs
{
char* ChooseFile()
{
NSWindow *keyWindow = [NSApp keyWindow];
char* path = nullptr;
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setCanChooseFiles:YES];
[panel setCanChooseDirectories:NO];
[panel setAllowsMultipleSelection:NO];
NSInteger clicked = [panel runModal];
if (clicked == NSFileHandlingPanelOKButton) {
for (NSURL *url in [panel URLs]) {
path = strdup([url fileSystemRepresentation]);
//const char* urlPath = [url fileSystemRepresentation];
//path = (char*)malloc(strlen(urlPath));
//strcpy(path, urlPath);
}
}
[keyWindow makeKeyWindow];
return path;
}
}