[comp.windows.x] Translation Table Mgmt Part II

skertic@sal-sun37.usc.edu (Robert Skertic) (10/21/89)

Reference Article 14970 and 14993
Subject: Translation Table Manipulation Part II

Please provide me with specific examples of the following:

1.  How do I set tm_table to my default translation table?
    I have defined my Translation table as follows:
    static String keys = "Ctrl<Key>D: noop()\n\...";
    static XtActionsRec no_actions[] = {{"noop",noop},};

2.  Why can't I get the following to work?

static Arg setargs[] = {
   {XtNtranslations, (XtTranslations)defaultTextTranslations},
};

XtSetValues(textwindow, setargs, XtNumber(setargs));

I get an error on defaultTextTranslations; The documentation
states that defaultTextTranslations is the default Trans Table
for a text widget!
I should not have to redefine it??  And, if I do, how should
I load both tables in the beginning?

I apologize for the basic nature of the above questions.  You
see there is no one to ask here and the references do not
give complete examples...as always, thanks ahead of time
for your help...frustrated--bob skertic

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (10/27/89)

> Reference Article 14970 and 14993

These number are not real useful to anyone who is reading this list via the
xpert mailing list...

> 1.  How do I set tm_table to my default translation table?
>     I have defined my Translation table as follows:
>     static String keys = "Ctrl<Key>D: noop()\n\...";
>     static XtActionsRec no_actions[] = {{"noop",noop},};

What do you mean "My default trans. table?"  If I understand you correctly you
want to have a translation table that is overrideable by the user, but is not
the same as the widget's default table.  If this is the case then you need to
put your translation table in the application's app-defaults file, and install
it in /usr/lib/X11/app-defaults/<Application Class name>.

> 2.  Why can't I get the following to work?

> static Arg setargs[] = {
>    {XtNtranslations, (XtTranslations)defaultTextTranslations},
> };

The translations passed into SetValues must first be put into the toolkits
internal format, use XtParseTranslationTable(defaultTextTranslations).  and then
pass the result to XtSetValues().

> I apologize for the basic nature of the above questions.

No, apology necessary, some people don't have wizards just down the hall.


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213

swick@ATHENA.MIT.EDU (Ralph R. Swick) (11/13/89)

> 1.  How do I set tm_table to my default translation table?

Assuming you are the writer of the widget class, then you
assign the (String) pointer either in the static class record
declaration or in the class_initialize procedure.  If you
aren't the widget class writer, then you shouldn't be changing
this field (but if you do, do it before the class_part_initialize
stage :-).

> 2.  Why can't I get the following to work?

XtSetValues will not do type conversion; defaultTextTranslations
is of type char[], and the XtNtranslations resource is of type
XtTranslations.  You'll have to do the conversion explicitly;
in this case by calling XtParseTranslationTable (which is merely
a short-hand for a more tedious XtConvert call).

> I should not have to redefine it??

defaultTextTranslations is not actually declared in any of the Xaw
header files, so you at least need to declare it to let the compiler
know what to do.

> if I do, how should
> I load both tables in the beginning?

You should specify your own table beginning with "#override" or
"#augment", as appropriate and declare it as the value of the
.translations resource in your app-defaults file.  Xt will
merge your own table with the Text widget default table automatically.