Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!ucbvax!ANDREW.CMU.EDU!gk5g+ From: gk5g+@ANDREW.CMU.EDU (Gary Keim) Newsgroups: comp.soft-sys.andrew Subject: Re: problems with menulists Message-ID: Date: 19 Oct 90 15:50:52 GMT References: <9010191054.AA10459@lazy.qt.IPA.FhG.de> Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 77 Excerpts from misc: 19-Oct-90 problems with menulists Christoph Mai@qt.IPA.FhG (1666) > and in the Initialize Class function > { > struct classinfo *classinfo = class_Load("textview"); > Newmenulist = menulist_New(); > bind_BindList(Bindings,NULL,newmenulist,classinfo); > } This is fine. Make Newmenulist a static (struct menulist *). The call to bind_BindList will effectively, (1) set up the proctable entries that will be called when their associated menuitems are called, (2) add all the menuitems described in the bind_Description to the menulist Newmenulist. The thing that is left out is that there has been no association made between the Newmenulist and the view that will respond to the menu choice. The best way to do this is (1) create and initialize a static menulist (Newmenulist) in InitializeClass. You've done this right; (2) after you've created the view that you want to associate with these menu items, make a call to menulist_DuplicateML(). Here it is: static struct menulist *Newmenulist; static struct bind_Description Bindings[]={ {NULL,NULL,0,"Quit",0,0,NULL,NULL}, {"Insert-Strings",NULL,0,"New Menu Card,Insert Strings",0,0,InsStrings, "Insert Strings"}, NULL }; static void InsStrings( txtv, rock ) struct textview *txtv; long rock; { printf(">InsStrings\n"); } boolean foo__InitializeClass(classID) struct classheader *classID; { struct classinfo *classinfo = class_Load("textview"); Newmenulist = menulist_New(); bind_BindList(Bindings,NULL,newmenulist,classinfo); return(TRUE); } void opennewwindow() { struct textview *newtextView; struct text *newtext; struct frame *frame; struct im *newim; newtext = text_New(); newtextView = textview_New(); view_SetDataObject((struct view *)newtextView, (struct dataobject *)newtext); menulist_ChainBeforeML(newtextView->menus, menulist_DuplicateML(Newmenulist,newtextView),0); frame = frame_New(); newIM = im_Create(NULL); frame_SetView(frame,newtextView); im_SetView(newIM,frame); } Happy Reunification! Gary Keim ATK Group