[comp.windows.x] XtCallbackPopdown usage

kevinj@boulder.Colorado.EDU (Kevin M. Jackson) (04/14/90)

I'm trying to get XtCallbackPopdown to work, and so far have had little
success.  The code fragments provided in O'Reilly Vol 5 are incorrect.
They specify that XtCallbackPopdown should be called as follows:

	Widget pshell, confirm;
	XtPopdownIDRec pop_rec;
	   
	confirm = XtCreateWidget(...)
	pshell = XtCreatePopupShell(...)
	pop_rec.shell_widget = pshell;
	pop_rec.enable_widget = confirm;
	XtAddCallback(confirm, XtCallbackPopdown, pop_rec);
	 
There are two problems with this.  XtAddCallback is missing its second
arguement (callback_name) and XtCallbackPopdown is being sent an
XtPopdownIDRec when it should be sent an XtPopdownIDRec pointer (or
XtPopdownID).  

I tried the following (SunOS 4.0.1, Sun3/260, mit server (patchlevel 9)).
Everthing compiles fine and runs until I try to exit the dialog with
the "button" command widget, but at that point I get a segmentation fault 
in XtPopdown (called by XtCallbackPopdown):

void CreateMessageBox (popup)
    XtPopdownID popup;
{
    Widget mesg, box, text, button;

    mesg = XtCreateManagedWidget(
          "mesg", panedWidgetClass, popup->shell_widget, NULL, 0);
    text = XtCreateManagedWidget(
          "text", asciiTextWidgetClass, mesg, NULL, 0);
    box = XtCreateManagedWidget(
          "box", boxWidgetClass, mesg, NULL, 0);
    button = XtCreateManagedWidget(
          "button", commandWidgetClass, box, NULL, 0);

    XtAddCallback(
          popup->enable_widget, XtNcallback, XtCallbackNonexclusive,
          popup->shell_widget);
    XtAddCallback(
          button, XtNcallback, XtCallbackPopdown, popup);
}

Any help is appreciated...


         ______________________________________________________________        
        (                                                              )       
 _______|  Kevin M. Jackson             kevinj@boulder.Colorado.EDU    |_______
        |                               kevinj@matrix.Colorado.EDU     |