Howdy,
I've created a C callable function to open the NSOpenPanel and convert the selected file name and path to a character array that's passed to the function:
... which works fine except that the main window loses it's focus after the NSOpenPanel is closed.
Is there a way to get a pointer to the window that's in focus at the beginning of the above function, and then return the focus to that window at the end of the function?
I've been searching, but don't really know what I'm looking for, so my search parameters are probably wrong.
Adios,
Cactus Dan
I've created a C callable function to open the NSOpenPanel and convert the selected file name and path to a character array that's passed to the function:
Code:
//Create open panel dialog
int callFileOpenDialog(int type, char **fName)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSOpenPanel *open = [NSOpenPanel openPanel];
NSString *pathName;
[open setResolvesAliases: true]; //Enable alias resolving
[open setAllowsMultipleSelection: false]; //Disable multiple selection
switch(type)
{
case FILE_SELECTION:
[open setCanChooseDirectories: false]; //Disable folder selection
[open setCanChooseFiles: true]; //Enable file selection
break;
case DIR_SELECTION:
[open setCanChooseDirectories: true]; //Enable folder selection
[open setCanChooseFiles: false]; //Disable file selection
break;
}
//Display open panel
int result = [open runModal];
if(result == NSOKButton)
{
switch(type)
{
case FILE_SELECTION:
pathName = [open filename];
break;
case DIR_SELECTION:
pathName = [open directory];
break;
}
*fName = (char *)malloc(strlen([pathName UTF8String]));
strcpy(*fName, [pathName UTF8String]);
[pool release];
return 1;
}
[pool release];
return 0;
}
... which works fine except that the main window loses it's focus after the NSOpenPanel is closed.
Is there a way to get a pointer to the window that's in focus at the beginning of the above function, and then return the focus to that window at the end of the function?
I've been searching, but don't really know what I'm looking for, so my search parameters are probably wrong.
Adios,
Cactus Dan