Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!ATHENA.MIT.EDU!kit From: kit@ATHENA.MIT.EDU (Chris D. Peterson) Newsgroups: comp.windows.x Subject: Re: Beginner's prblem with widgets Message-ID: <8902151832.AA07441@DORA.MIT.EDU> Date: 15 Feb 89 18:32:36 GMT References: <2200@vu-vlsi.Villanova.EDU> Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 87 The problem you are having it a misunderstanding of what the x and y resources of a child mean to the parent. The parent (in this case the form widget) is free to move his managed children wherever he wants to, and ignore their x and y locations if he so chooses. This is what the form is doing. In fact what is actually happening is the the label and command widget are on top of one another. Your callback is fine, either of the following main's will do the right thing for you. They will act differently when resized. I will leave it as an exercise for the reader to figure out why :-). Case 1: ------- int main(argc,argv) unsigned int argc; char **argv; { Widget toplevel,box,label,command; Arg arg[25]; Cardinal n; toplevel = XtInitialize("goodbye","Goodbye",NULL,0,&argc,argv); box = XtCreateManagedWidget("box",formWidgetClass,toplevel,(Arg *)NULL,0); n=0; XtSetArg(arg[n],XtNlabel,"Goodbye world"); n++; label = XtCreateManagedWidget("label",labelWidgetClass,box,arg,n); n=0; XtSetArg(arg[n],XtNlabel,"Click and die"); n++; XtSetArg(arg[n],XtNfromVert, label); n++; command = XtCreateManagedWidget("command",commandWidgetClass,box,arg,n); XtAddCallback(command,XtNcallback,Callback,NULL); XtRealizeWidget(toplevel); XtMainLoop(); } Case 2: ------- change the line #include to #include int main(argc,argv) unsigned int argc; char **argv; { Widget toplevel,box,label,command; Arg arg[25]; unsigned int n; toplevel = XtInitialize("goodbye","Goodbye",NULL,0,&argc,argv); box = XtCreateManagedWidget("box",boxWidgetClass,toplevel,(Arg *)NULL,0); n=0; XtSetArg(arg[n],XtNlabel,"Goodbye world"); n++; label = XtCreateManagedWidget("label",labelWidgetClass,box,arg,n); n=0; XtSetArg(arg[n],XtNlabel,"Click and die"); n++; command = XtCreateManagedWidget("command",commandWidgetClass,box,arg,n); XtAddCallback(command,XtNcallback,Callback,NULL); XtRealizeWidget(toplevel); XtMainLoop(); } Chris D. Peterson MIT X Consortium / Project Athena Net: kit@athena.mit.edu Phone: (617) 253 - 1326 USMail: MIT - Room E40-321 77 Massachusetts Ave. Cambridge, MA 02139