Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!athena.mit.edu!dschmidt
From: dschmidt@athena.mit.edu (Dan Schmidt)
Newsgroups: comp.windows.x
Subject: Re: XtAddActions/XtOverrideTranslations
Keywords: Changing event handling for widgets..
Message-ID: <6247@bloom-beacon.MIT.EDU>
Date: 16 Jul 88 06:26:21 GMT
References: <4495@pasteur.Berkeley.Edu>
Sender: daemon@bloom-beacon.MIT.EDU
Reply-To: dschmidt@athena.mit.edu (Dan Schmidt)
Organization: Massachusetts Institute of Technology
Lines: 54

In article <4495@pasteur.Berkeley.Edu> dheller@cory.Berkeley.EDU (Dan Heller) writes:
 > 
 > A collegue and I are trying to force a middle button event on a
 > widget to go to a specific routine.  So, we stumbled thru some
 > of the vague documentation on pages 91 and 92 of the X Toolkit
 > Intrinsics to try to figure out how to do this.
 > 
 > The Doc says to use XtOverrideTranslations() to merge in our new
 > translation table.  But of course, it didn't tell us that we needed
 > to call something else in order for these translations to be 
 > recognized.  We figured that we should call XtAddActions() first
 > to register actions that we were going to reference when trying
 > to merge our new translation table in.
 > 
 > Finally, we got no more error messages, but the new event wasn't
 > registered.  We tried all kinds of widgets -- label widgets,
 > command widgets, and even one of my own.  It doesn't seem like
 > the type of widget should matter, but I tried a few anyway just
 > in case...
 > 
 > We finally worked around the problem by calling XtAddEventHandler()
 > to register the actions and events desired and it worked fine.
 > 
 > Can someone tell me what we could have done to get the new translation
 > table working correctly?
 > Dan Heller	 

OK... This is what to do:

1.  Make your XtActionList:

  static XtActionsRec actionTable[] = {"Foo",foo};

2.  Make your translation table:

  String translationtable = ":Foo()";

3.  Let the translation manager know about your action table:

  XtAddActions(actionTable,XtNumber(actionTable));

4.  Put in your new translation table:

  XtOverrideTranslations(w,XtParseTranslationTable(translationtable));

Now, whenever a button is pressed in the widget w, the procedure foo()
(not Foo(); Foo() -> Foo -> foo via the actionTable) is called.

I actually thought that this was one of the clearer parts of the
manual... which means of course that it was barely understandable...

           Dan Schmidt          Something I learned today                     
    dschmidt@athena.mit.edu     Black and white is always gray  -- Husker Du  
It was a giant Adenoid.  At least as big as St. Paul's, and growing hour by
hour.  London, perhaps all England, was in mortal peril! -- Thomas Pynchon