[comp.windows.x] Binding keypad enter to an action

jmberkley@watnext.waterloo.edu (J. Michael Berkley) (02/28/89)

Using C and the toolkit, how can you add the keypad enter key to the
translation table.  I can do it as a resource using xrdb, but I can't
find a way to do it from a C program.

This is what I've tried so far:

/* These don't work
#define XDEFTRANS "<Key>KB_Enter: print-selection()"
#define XDEFTRANS "<Key>Enter: print-selection()"
*/
/* This does, but binds <meta>S, not <enter> which is what I want. */
#define XDEFTRANS "Meta<Key>S: print-selection()"

XtOverrideTranslations(w,XtParseTranslationTable(XDEFTRANS));

meo@stiatl.UUCP (Miles O'Neal) (03/01/89)

In article <8321@watcgl.waterloo.edu> jmberkley@watnext.waterloo.edu (J. Michael Berkley) writes:
>Using C and the toolkit, how can you add the keypad enter key to the
>translation table.  I can do it as a resource using xrdb, but I can't
>find a way to do it from a C program.

You didn't mention your hardware, but I know our Roadrunners are set
up like this. We set things up via xmodmap because we are using a version
of the server someone else has tweaked, but know what we need to change
when we start supporting our server. Look in the server/ddx/<your hardware>
directory at the <your hardware>KeyMap.c file. This may just be how it is
handled for Suns. I'm not sure because we wiped all the other stuff during
a disk cleanup (it's on tape, but not very handy).

-Miles
gatech!stiatl!meo
meo@stiatl.gatech.edu

jmberkley@watnext.waterloo.edu (J. Michael Berkley) (03/02/89)

In article <3447@stiatl.UUCP> meo@stiatl.UUCP (Miles O'Neal) writes:
>In article <8321@watcgl.waterloo.edu> jmberkley@watnext.waterloo.edu (J. Michael Berkley) writes:
>>Using C and the toolkit, how can you add the keypad enter key to the
>>translation table.  I can do it as a resource using xrdb, but I can't
>>find a way to do it from a C program.
>
>You didn't mention your hardware, but I know our Roadrunners are set
>up like this. We set things up via xmodmap because we are using a version
>of the server someone else has tweaked, but know what we need to change
>when we start supporting our server. Look in the server/ddx/<your hardware>
>directory at the <your hardware>KeyMap.c file.

No, that's not it.  In lib/Xaw/TextTr.c there are entries for Key
translations:

	char defaultTextTranslations[] =
	"\
	.
	.
	<Key>Right:	forward-character() \n\
	.
	.
	";

In my code, I tried:

    XtOverrideTranslations(w,
	XtParseTranslationTable("<Key>KB_Enter: print-selection()"));

The "KB_Enter" comes from lib/X/ks_names.h.  This piece of C code does
not work.  This does work with other keys, eg. "meta<Key>S".

In my .Xresources file, I can say:

    stuff*Text.Translations: #override \
	<KeyPress>KP_Enter: print-selection()

This does do the correct translation binding, but of course I don't
want all of my users to have to add this to their .Xresources file.


******************************************
* Mike Berkley, University of Waterloo   *
* PAMI Lab                               *
* jmberkley@watnext.waterloo.edu         *
* jmberkley@watnext.UWaterloo.CA         *
* {utai,uunet}!watmath!watnext!jmberkley *
******************************************