[comp.windows.x] Translation Mgr and <Key>: vs <Key>a:

grp@magpie.unify.uucp (Greg Pasquariello) (06/06/90)

I have run into a translation manager problem with event sequences, that
_seems_ to be a bug. Given that I have a resource file with translations in 
it, the translation manager behaves differently in two situations where I 
would expect it to work the same way.

Consider a resource file with the following lines...

*Command*translations:#replace\n\
	<Key>Escape,<Key>a:	EscapeSeq()\n\
	<Key>a:			KeyPressed()

This behaves as I would expect it to; pressing "a" invokes KeyPressed() while
pressing "ESC-a" invokes EscapeSeq().  However, in the situation where

*Command*translations:#replace\n\
	<Key>Escape,<Key>a:	EscapeSeq()\n\
	<Key>:			KeyPressed()

pressing "a" does nothing while pressing "ESC-a" works correctly.  

Am I missing something here?  I have poured over various books, manuals, etc,
but cannot seem to determine if this is a bug or expected behavior. 

Following is the small test program I used to ascertain my problem.

================<CUT HERE>================

#include    	<X11/Intrinsic.h>
#include	<X11/Box.h>
#include	<X11/Command.h>

Arg	wargs[10];
int	n;

static void EscapeSeq()
{
    printf("Escape Sequence\n");
}

static void KeyPressed()
{
    printf("Key pressed\n");
}

    
XtActionsRec	actTab[] =
{
    {"EscapeSeq", EscapeSeq },
    {"KeyPressed", KeyPressed },
};

main(argc, argv)
int	argc;
char	**argv;
{
	Widget  toplevel;
	Widget  field;
	Widget	control;

	toplevel = XtInitialize(argv[0], "TestClass", NULL, 0, &argc, argv);

	XtAddActions(actTab, XtNumber(actTab));
	n = 0;
	control = XtCreateManagedWidget("control", 
					boxWidgetClass,
					toplevel,
					wargs,
					n);

	n = 0;
	field = XtCreateManagedWidget("field",
				      commandWidgetClass,
				      control,
				      wargs,
				      n);
	
	XtRealizeWidget(toplevel);
	XtMainLoop();
}






--
-------------------------------------------------------------------------------
Greg Pasquariello	(916) 920-9092		...!uunet!unify!grp
Unify Corporation

converse@EXPO.LCS.MIT.EDU (Donna Converse) (06/07/90)

> I have run into a translation manager problem with event sequences, that
> _seems_ to be a bug. Given that I have a resource file with translations in 
> it, the translation manager behaves differently in two situations where I 
> would expect it to work the same way.
> 
> Consider a resource file with the following lines...
> 
> *Command*translations:#replace\n\
> 	<Key>Escape,<Key>a:	EscapeSeq()\n\
> 	<Key>a:			KeyPressed()
> 
> This behaves as I would expect it to; pressing "a" invokes KeyPressed() while
> pressing "ESC-a" invokes EscapeSeq().  However, in the situation where
> 
> *Command*translations:#replace\n\
> 	<Key>Escape,<Key>a:	EscapeSeq()\n\
> 	<Key>:			KeyPressed()
> 
> pressing "a" does nothing while pressing "ESC-a" works correctly.  
> 
> Am I missing something here?  I have poured over various books, manuals, etc,
> but cannot seem to determine if this is a bug or expected behavior. 

The exact behavior is not specified; this is an area of the Xt Intrinsics
which needs more definition.  And it's current behavior doesn't clearly
strike me as being right, either, in this particular case.  It also seems
to me that the documentation implies that in the second of the two examples
that you give, pressing "escape a" should result in KeyPressed() and 
EscapeSeq() executing, but it doesn't work that way when I try it out.

This happens to work to get the behavior that you want:

*Command*translations:#replace\n\
	<Key>Escape,<Key>a:	EscapeSeq()\n\
	<Key>a:			KeyPressed()\n\
	<Key>:			KeyPressed()


The problem is being addressed within the X Consortium group responsible
for the Xt Intrinsics.


Donna Converse
converse@expo.lcs.mit.edu