meo@stiatl.UUCP (Miles O'Neal) (02/08/89)
Regarding translation - action routines (event handlers): If I need the same code in several types of widgets (eg, IgnoreChar - a routine to throw away unwanted characters), do I need a static copy of this in each widget.c file, or can I just stick a non-static version in a common library? Thanks, Miles (gatech!stiatl!meo)
kit@ATHENA.MIT.EDU (Chris D. Peterson) (02/10/89)
> If I need the same code in several types of widgets (eg, IgnoreChar - > a routine to throw away unwanted characters), do I need a static copy > of this in each widget.c file, or can I just stick a non-static version > in a common library? I suppose that you could declare the function as external in the widget, then add it to the widget's action table. This should cause everything to work correctly. I will leave it to you to figure out how to make sure that the function gets linked into the application. If you are writing an application this is much easier, you just need to add the action routine to your application's AppContext using XtAppAddActions(). The Intrinsics search for an action routine in widget, and then up through all of its superclasses. If it finds the routine it stops searching and uses the one that it found. If it still hasn't found it after searching through all of the widget's superclasses it then looks for any action routines that the application has defined. 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
meo@stiatl.UUCP (Miles O'Neal) (02/10/89)
In article <8902091719.AA02641@DORA.MIT.EDU> kit@ATHENA.MIT.EDU (Chris D. Peterson) writes: >> If I need the same code in several types of widgets (eg, IgnoreChar - >> a routine to throw away unwanted characters), do I need a static copy >> of this in each widget.c file, or can I just stick a non-static version >> in a common library? >I suppose that you could declare the function as external in the widget, >then add it to the widget's action table. This should cause everything >to work correctly. This is the type of thing I had in mind. What I was wondering was whether, since "interrupt handlers are not reentrant" (someone - Ralph Swick, maybe?) speaking at the recent MIT X11 seminar), is this a safe thing to do? In other words, am I confusing two issues here? All of this assumes, of course, that I write my code perfectly... (lest the Softies bust me). -Miles