john@csrnxt1.ae.utexas.edu (John R. Schutz) (12/22/90)
Howdy all you programmers out there! I am looking for a little help. I have a need for a pick list in a program, so I wrote some code to do this (surprise surprise!). Anyways, it works OK, but has one annoying bug. Before you can select anything in it, you must first click inbetween to items and then you can select a item in the list. Anyways, I would really apprectiate some help. Please don't beat me about the head about inefficiencies, because I am still learning Objective-C. But I would appreciate any tips on how to do this better. Thanks! - openuppicklistpanel:sender; { FILE *locationfile; NXSize nxsCell,nxsList; char tstr[100]; BOOL filefound; if (firsttimeforlocations) { if ((locationfile=fopen("gpscoord.xyz","r"))!=(FILE *)NULL) { [locationscroll setVertScrollerRequired:YES]; [locationscroll setBorderType:NX_BEZEL]; [locationscroll getContentSize:&nxsList]; [locationmatrix getCellSize:&nxsCell]; nxsCell.width=nxsList.width; [locationmatrix setCellSize:&nxsCell]; [locationmatrix setAutoscroll:YES]; [locationscroll setDocView:locationmatrix]; numprows=0; while ([locationmatrix cellCount])[locationmatrix removeRowAt:0 andFree:YES]; [locationmatrix sizeToCells]; fgets(tstr,99,locationfile); while ((!feof(locationfile))&&(strcmp(tstr,"\n")!=0)) { fgets(tstr,99,locationfile); [locationmatrix addRow]; [locationmatrix sizeToCells]; [[locationmatrix cellAt:numprows :0] setStringValue:tstr]; numprows++; } [locationmatrix removeRowAt:numprows andFree:YES]; [locationmatrix removeRowAt:numprows-1 andFree:YES]; } else { NXRunAlertPanel("NeXT Almanac Error","File \"gpscoord.xyz\" not found.","OK",NULL,NULL); filefound=NO; } } if (filefound) { [locationscroll display]; [locationpanel makeKeyAndOrderFront:self]; } } Thanks for any help! john