When I open an NSOpenPanel to get a file and click OK It is not responding to the OK button the first time? If seems to disappear then reappear with an empty folder. This causes me to have to back out of the folder and go back into it to select the item again. After that it loads just fine? I have googled a looked at other examples and mine seems no different? I made a demo video to better demonstrate the issue here
http://sbtraveler.tv/odd/NSOpenPanel.mov
http://sbtraveler.tv/odd/NSOpenPanel.mov
Code:
- (IBAction)importItem:(id)sender{
NSOpenPanel *openDlg = [NSOpenPanel openPanel];;
NSString *pathName = @"/Users/larspro/Documents/ERad files/items database";
[openDlg setDirectoryURL:[NSURL URLWithString:pathName]];
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:NO];
[openDlg runModal];
NSInteger result = [openDlg runModal];
if (result == NSFileHandlingPanelCancelButton) {
[openDlg orderOut:self];
}
if ( result == NSOKButton) {
if (counter == 0) {
item1Array = [[NSMutableArray alloc] initWithContentsOfURL:openDlg.URL];
NSImage *importImage = [[NSImage alloc] initWithData:[item1Array objectAtIndex:0]];
item1ImageView.image = importImage;
firstName.stringValue = [item1Array objectAtIndex:1];
[openDlg orderOut:self];
}
if (counter == 1) {
item2Array = [[NSMutableArray alloc] initWithContentsOfURL:openDlg.URL];
NSImage *importImage = [[NSImage alloc] initWithData:[item2Array objectAtIndex:0]];
item2ImageView.image = importImage;
secondName.stringValue = [item2Array objectAtIndex:1];
[openDlg orderOut:self];
}
if (counter == 2) {
item3Array = [[NSMutableArray alloc] initWithContentsOfURL:openDlg.URL];
NSImage *importImage = [[NSImage alloc] initWithData:[item3Array objectAtIndex:0]];
item3ImageView.image = importImage;
thirdName.stringValue = [item3Array objectAtIndex:1];
[openDlg orderOut:self];
}
if (counter == 3) {
item4Array = [[NSMutableArray alloc] initWithContentsOfURL:openDlg.URL];
NSImage *importImage = [[NSImage alloc] initWithData:[item4Array objectAtIndex:0]];
item4ImageView.image = importImage;
forthName.stringValue = [item4Array objectAtIndex:1];
[openDlg orderOut:self];
}
counter++;
}
}
Last edited: