- First commit to gitea
This commit is contained in:
29
GUIDialogs.mm
Normal file
29
GUIDialogs.mm
Normal file
@@ -0,0 +1,29 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user