Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!apple!atncpc!bruce From: bruce@atncpc.UUCP (Bruce Henderson) Newsgroups: comp.sys.next Subject: Re: Deleting Menu Cells Summary: An answer Keywords: Help Message-ID: <272@atncpc.UUCP> Date: 7 Jun 90 16:27:29 GMT References: Deleting Menu Cells <266d6c7b.40b2@petunia.CalPoly.EDU> Distribution: usa Organization: Ashton Tate NCPC, San Jose, CA. Lines: 85 In article <266d6c7b.40b2@petunia.CalPoly.EDU>, ebostick@polyslo.CalPoly.EDU (Edward Bostick) writes: > > > I'm working on a NeXT application and I have a submenu that > I would like to remove menu cells form. I can disable, enable, > add, sizeToFit, update, and free, but I cannot get the actual > cell to disappear form the submenu. I have look through the > Edward S. Bostick (ebostick@polyslo.calpoly.edu) yeah, this used to get me, and I still forget it occasionally. I usually make it work like this: - removeMenuCell:theMenu :(int)cellNum { id matrix; [theMenu disableFlushWindow]; /* this gets rid of nasty flicker */ matrix = [theMenu itemList]; [matrix removeRowAt:cellNum andFree:YES]; /* ^ deletes the unwanted cell... */ [theMenu sizeToFit]; /* adjust menu to new size */ [[theMenu reenableFlushWindow] flushWindow]; /* don't forget the above line, if you do you menu will */ /* be hozed forever, and it will never hilight again! */ return self; } This should rip out any unwanted menu Items, providing you know it's number. If you only have the cell's title, you can do this: - removeMenuCell:theMenu name:(const char*)cellTitle { int i, count; id matrix, cells; id cell; const char* title; /* once again we will disable window flushing so that */ /* we don't have screen flicker during the operation */ /* the reason this works, remember a menu is a subclass */ /* of window */ [theMenu disableFlushWindow]; matrix = [theMenu itemList]; /* next we will need the list of cells... */ cells = [matrix itemList]; /* and the number of cells in the matrix (you'll see why) */ count = [cells count]; /* now we will walk the list comparing titles */ for(i = 0; i < count; i++) { cell = [cells objectAt:i]; title = [cell title]; if(s && !strcmp(s, cellTitle) { [remove RowAt:i andFree:YES]; break; } } /* now resize the menu */ [theMenu sizeToFit]; /* re-enable the window flushing */ [[theMenu reenableFlushWindow] flushWindow]; return self; } If you still have problem, E-Mail me and we'll figureit out. I hope this work [sorry if any of you netters think this is really boring and old hat, but I do remember the exciting days when I was still new to the machine, and it all seemed like wonderful magic.] Bruce Henderson User Interface KGB Ashton - Tate NeXTeam