Path: utzoo!attcan!uunet!husc6!think!snorkelwacker!bloom-beacon!MAPS.CS.CMU.EDU!Jean-Christophe.Dhellemmes From: Jean-Christophe.Dhellemmes@MAPS.CS.CMU.EDU Newsgroups: comp.windows.x Subject: translation tables conflict Message-ID: <9006011949.AA02414@ATHENA.MIT.EDU> Date: 1 Jun 90 19:40:44 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 120 I am using X11 R4 and the Athena widget toolkit. I would like to have a menu popup when I press Btn2 in my application window's background, and a different menu popup with the same button when I am in a command widget. For that I wrote the following (very simple) program: ------------------------------------------------------------------ /************* ** INCLUDES ** *************/ #include #include #include #include #include #include /********* ** MAIN ** *********/ main(argc,argv) int argc; char *argv[]; { Arg xarg[16]; XtTranslations trans; Widget top,form,button,popup1,popup2,wg; /* top window */ top = XtInitialize("mytop","MAPS",NULL,NULL,&argc,argv); form = XtCreateManagedWidget("form",formWidgetClass,top,NULL,NULL); /* menu 1 */ popup1 = XtCreatePopupShell("popup1",overrideShellWidgetClass,top,NULL,0); trans = XtParseTranslationTable(": MenuPopdown(popup1)"); XtOverrideTranslations(popup1, trans); XtSetArg(xarg[0],XtNlabel,"Menu1"); wg = XtCreateManagedWidget("button1",labelWidgetClass,popup1,xarg,1); XtMoveWidget(popup1,100,100); /* menu 2 */ popup2 = XtCreatePopupShell("popup2",overrideShellWidgetClass,top,NULL,0); trans = XtParseTranslationTable(": MenuPopdown(popup2)"); XtOverrideTranslations(popup2, trans); XtSetArg(xarg[0],XtNlabel,"Menu2"); wg = XtCreateManagedWidget("button2",labelWidgetClass,popup2,xarg,1); XtMoveWidget(popup2,100,140); /* button */ XtSetArg(xarg[0],XtNhorizDistance,50); XtSetArg(xarg[1],XtNvertDistance,50); XtSetArg(xarg[2],XtNlabel,"BUTTON"); button = XtCreateManagedWidget("button",commandWidgetClass,form,xarg,3); /* translation tables */ trans = XtParseTranslationTable(": MenuPopup(popup1)"); XtOverrideTranslations(top, trans); trans = XtParseTranslationTable(": MenuPopup(popup2)"); XtOverrideTranslations(button, trans); /* start application */ XtConfigureWidget(top,100,100,200,200,1); /* set size */ XtRealizeWidget(top); XtMainLoop(); } ----------------------------------------------------------------- This program doesn't work. When I press Btn2 in the command widget, the top window translation table is executed instead if the command widget's, and the popup1 appears wherever I have pressed Btn2. I have tried many different ways of doing that, with no success. In this program, the hierarchy is: top : MenuPopup(popup1) <-------. /|\ \ / | popup1 : MenuPopdown(popup1) \ / | \ / popup2 : MenuPopdown(popup2) \_ Shouldn't the / / priority be form / for button ? | / button : MenuPopup(popup2) <------------' As Tom Tulinsky suggested in his post of May-16-1990, I tried to move the button translation up to the form, but it didn't work. I don't know if this problem is linked to the translation tables management or to the popup shells management. Under R3, I used a trick to achieve my goals, by switching back and forth the translation table of the top window on and events for the command widget. This doesn't work anymore under R4 because the command widget now receives a event before (?) the popup shell pops up, and therefore resets the translation table to popup the wrong shell. 1) Do I do something wrong in the program above ? 2) Is there a way to set-up translation tables so that a child's translation table overrides the one of his parents ? 3) Is there an other way to do menu-switching when in a given button ? I think this is an important feature I want to have in my window manager. I hope I asked my questions clearly and that somebody will take the time to explain to me how all this works. If I receive many answers/solutions, I'll post a summary or/and forward the solutions to whoever wants them. Thanks in advance. * JCD (jcd@maps.cs.cmu.edu)