ebostick@polyslo.CalPoly.EDU (Edward Bostick) (06/07/90)
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 Application kit header files that are superclasses of the menu object and the menucell object for a method that would do what I would like, but I have had no luck. I must be doing something wrong. If anyone has any suggestions on what I should be doing or where I could find the answers I'm looking for I would be very thankful. Edward S. Bostick (ebostick@polyslo.calpoly.edu)
bruce@atncpc.UUCP (Bruce Henderson) (06/07/90)
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