Path: utzoo!attcan!uunet!mcsun!unido!infbs!bredex!uwe From: uwe@bredex.UUCP ( BREDEX GmbH) Newsgroups: comp.windows.x Subject: problems with event handler in Motif 1.0.a Message-ID: <792@bredex.UUCP> Date: 12 Apr 90 10:11:31 GMT Reply-To: uwe@bredex.UUCP (Uwe Faustmann - BREDEX GmbH) Organization: BREDEX GmbH, Braunschweig, F.R.Germany Lines: 148 Dear xperts, we have a problem using popup menus in Motif. The program attached below should do the following: - use a form widget with an included label widget - add an event handler(ButtonPress) to the form and the label - popup a different menu dependend on the widget the mouse button was pressed on What actually happens is a bit strange: if you use MB3 on the form, all is as expected if you use MB3 on the label, the event handler is called, but the widget id is that of the form if you press MB2 and then MB3, you get the right widget id We have RTFM, and we have UTSL, but we have found nothing to explain this behavior. Is it documented somewhere, is it a bug in Motif or are we just missing something? BTW, this is Motif 1.0.a on a DECstation 3100, mwm running. Thanks, Uwe \|||/ Uwe Faustmann, Bredex GmbH o o Braunschweig, West Germany > uwe@bredex.uucp =========================================================== #include #include #include #include #include #include Display *display; int *screen; XtAppContext appContext; void popupMenu (widget, menu, event) Widget widget; Widget menu; XEvent *event; { if (event->xbutton.button != Button3) return; XmMenuPosition(menu, event); XtManageChild (menu); } main (argc, argv) int argc; char *argv[]; { Widget shell; Widget form; Widget label; Widget menu1, menu2; Widget button1, button2; Arg args[10]; Cardinal n; /* * Initialize the X Toolkit */ XtToolkitInitialize (); /* * Create an application context */ appContext = XtCreateApplicationContext (); /* * Open the display */ display = XtOpenDisplay (appContext, (String) NULL, "test", "Test", (XrmOptionDescRec *) NULL, 0, &argc, argv); if ( !display ) { printf ("Cannot open display\n"); exit (1); } /* * Create an application shell */ shell = XtAppCreateShell ("test", "Test", applicationShellWidgetClass, display, (ArgList) NULL, 0); /* * Create a container */ form = XmCreateForm (shell, "", NULL, 0); XtManageChild (form); menu1 = XmCreatePopupMenu (form, "Menu1", NULL, 0); button1 = XmCreatePushButton (menu1, "Button1", NULL, 0); XtManageChild (button1); XtAddEventHandler (form, ButtonPressMask, False, popupMenu, menu1); /* * Create a label inside the container */ label = XmCreateLabel (form, "Label", NULL, 0); XtManageChild (label); menu2 = XmCreatePopupMenu (label, "Menu2", NULL, 0); button2 = XmCreatePushButton (menu2, "Button2", NULL, 0); XtManageChild (button2); XtAddEventHandler (label, ButtonPressMask, False, popupMenu, menu2); /* * get the show rolling */ XtRealizeWidget (shell); XtAppMainLoop (appContext); }