Re: XForms: KeyCodes in XForms

Orn E. Hansen (oe.hansen@oehansen.pp.se)
Sat, 20 Sep 1997 12:03:25 +0200 (CET DST)

To subscribers of the xforms list from "Orn E. Hansen" <oe.hansen@oehansen.pp.se> :

Registration of an Event routine to handle Key press, has an apparant
flaw that makes the use of it to handle dead_keys, on an abstract basis,
hard. The pre-handler only handles keycodes, that are passed to the
event handler, and it would be nice if one was able to tell the main
handler that it has and should process the keysym instead of the keycode
itself.

Is this possible, or will this be possible in future versions? It is
evident that they handling of keycodes is absorbing the dead keys and
preventing them from behaving normally.

=DEann 09-Sep-97 skrifar Frank Stefani:
>=20
> In your main() ore more precisely before fl_do_forms, try:
>=20
> fl_register_raw_callback(fd_my_frm->my_frm, KeyPressMask, xevhandler)=
;=20
>=20
> and create the appropriate XEvent handler function:
>=20

Modifying your example...

static unsigned char *accents[] =3D {
NULL, /* No accent */
"a=E0e=E8i=ECo=F2u=F9", /* grave */
"a=E1e=E9i=EDo=F3u=FAy=FD", /* acute */
"a=E2e=EAi=EEo=F4u=FB", /* circumflex */
"a=E3n=F1o=F5", /* tilde */
...
"a=E4e=EBi=EFo=F6u=FCy=FF", /* diaeresis */
"a=E5", /* abovering */
...
};

int xevhandler(FL_FORM *form, void *xev)
{
XKeyEvent *xkey;
XButtonEvent *xbutton;
int keysym;
static int accent =3D 0;
=20
switch ( ((XKeyEvent *)xev)->type ) {
case KeyPress:
xkey =3D (XKeyEvent *)xev;
keysym =3D XKeycodeToKeysym(xkey->display, xkey->keycode, 0);
switch ( keysym ) {
case XK_dead_acute:
case XK_dead_grave:
case XK_dead_tilde:
case XK_dead_abovering:
...
case XK_dead_circumflex:
...
case XK_dead_diaeresis:
case XK_dead_caron:
case XK_dead_cedilla:
accent =3D (keysym & 15) + 1;
return FL_PREEMPT;
default:
if (accent && isascii(keysym)) {
unsigned char *ap;

if ((accents[accent]) && (ap =3D strchr(accents[accent], keysy=
m))
if ((ap - accents[accent]) % 2 =3D=3D 0)
/* Here I would like to return the KeySym of ap[1] */
/* and have the main handler process it as a normal */
/* KeySym. It can't acquire this key by KeyCode, */
/* As there is no Key assigned to this value, they */
/* are only available as secondary through dead */
/* keys... */
}
} /* keysym */
case ButtonPress:
xbutton =3D (XButtonEvent*)xev;
switch ( xbutton->button ) {
case 1: /* Left mouse button */
...
break;
case 2: /* middle mouse button */
=20
...
} /* switch xev-type */
} /* xevhandler */
=20

The functionality of the above routine, should be built into the
function of 'XKeycodeToKeysym'... it does behave correctly in some other
situations, wheras I asked if xforms specifically requests a 'RAW' event
handling that may bypass this function? and if so, will future versions
behave the same way?

-------------------------------------------------------------------------=

---
Orn Einar Hansen                         oe.hansen@oehansen.pp.se
                                          oehansen@daimi.aau.dk
                                        voice+fax; +46 035 217194
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/