[comp.windows.x] XtAddActions/XtOverrideTranslations

dheller@cory.Berkeley.EDU (Dan Heller) (07/16/88)

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	<island!argv@sun.com>

dschmidt@athena.mit.edu (Dan Schmidt) (07/16/88)

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	<island!argv@sun.com> 

OK... This is what to do:

1.  Make your XtActionList:

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

2.  Make your translation table:

  String translationtable = "<BtnDown>: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

swick@ATHENA.MIT.EDU (Ralph R. Swick) (07/18/88)

You don't specify the precise calling sequence you were using but
there is a known bug that causes XtOverrideTranslations and
XtAugmentTranslations to fail silently if called on a realized
widget.  The work-around is to call XtOverride/Augment before
realizing the widget.

fred@hpcvlx.HP.COM (Fred Taft) (07/18/88)

There are some problems with the toolkit in the augment/override code,
if you are trying to augment/override translations for a widget which
has already been realized.

We submitted fixes 4 months ago, but have yet to see the fixes 'blessed'.
Until these fixes are rolled into the toolkit, it will probably be
difficult for you to use these features unless you are content to do so
only with unrealized widgets.

asente@WSL.DEC.COM (07/23/88)

The bugs regarding changing translations not working for realized
widgets will be fixed in the next release of the toolkit (i.e. we have fixed it).

	-paul asente

fred%hpcvxrm@HPLABS.HP.COM (Fred Taft) (07/26/88)

Does your referral to the next version of the toolkit imply R3?  If so, then
that is too late for many people.  A fix was submitted four months ago, and
it should have been handled by MIT in the same fashion as all other fixes.
I find it hard to believe that a 'blessed' patch for this bug has taken so
long to come out.  


  - Fred Taft