Xref: utzoo comp.windows.x:33650 comp.windows.x.motif:2109 Path: utzoo!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!david From: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Newsgroups: comp.windows.x,comp.windows.x.motif Subject: Re: Callback Arguements in WCL Message-ID: <11686@jpl-devvax.JPL.NASA.GOV> Date: 5 Mar 91 19:28:02 GMT References: <499@shrike.AUSTIN.LOCKHEED.COM> Reply-To: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Distribution: usa Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 82 lossau@AUSTIN.LOCKHEED.COM (Kathleen O Lossau) writes: > >Is there anyone familar enough with the WCL (Widget Creation Library) >to tell me if there is a way to pass information to a callback from >WCL. WCL seems to handle the passing of all information. The resource >file cannot specify any call-data. You can only pass strings reliably. You *can* register client data which is sent *if* there is nothing specified in the resource file within the parens. Like this: *foo.callback: MyCallback This will send the registered client data to the callback. However, if the user does this: *foo.callback: MyCallback() Then your callback will get "\0" instead. There is absolutely no possibly way of passing client defined call data - that is passed by the widget invoking the callback, Wcl does not get involved with that stuff at all. In fact, Wcl does all the string-to-callback conversion when the widget is created, not when the callback is invoked. >I assume that I am missing something basic. (I'm new to WCL) and would like >it to work for me, but I'm not sure how to (other than globals --- yuch!!!) >pass information (like another widget) to a callback. You can pass the name of the widget as the argument to the callback or action, and then invoke WcFullNameToWidget, which is an extension of XtNameToWidget. Look at the WcCallb.c file to see how Wcl implements the standard library supplied callbacks. These might give you some hints. Something I regularly do is this: When I create a widget and I need to relate some application information to the widget, I use the wcCallback creation time callback mechanism, and the X Context Manager. Let's say I need to relate an object `foo' to a widget `bar'. I might do this: *bar.wcCallback: CreateFoo( something ) *bar.callback: Respond The callback would do this: void CreateFooCB( w, useful, ignore ) Widget w; char* useful; caddr_t ignore; { /* create a Foo instance */ Foo* foo = FooCreate( useful ); XSaveContext( dpy, w, anything, foo ); } void RespondCB( w, nothing, ignore ) Widget w; char* nothing; caddr_t ignore; { /* Assume I need to fool around with the Foo instance ** related to this widget when the widget was created */ Foo* foo; XFindContext( dpy, w, anything, &foo ); FooManipulate(foo); } ------------------------------------------------------------------------- David Smyth david@jpl-devvax.jpl.nasa.gov Senior Software Engineer, seismo!cit-vax!jpl-devvax!david X and Object Guru. (818)393-0983 Jet Propulsion Lab, M/S 230-103, 4800 Oak Grove Drive, Pasadena, CA 91109 ------------------------------------------------------------------------- What's the earliest possible date you can't prove it won't be done by? - Tom DeMarco -------------------------------------------------------------------------