Re: XForms: KeyPress problems

Steve Lamont (spl@szechuan.ucsd.edu)
Tue, 21 Apr 98 06:22:59 PDT

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> Here is the main part of my KeyPress handler:
>
> int Keyboard(FL_OBJECT *ob, Window win, int w, int h, XEvent *xev, void
> *udata){
>
> char key[5];
> KeySim keysim;
>
> XLookupString((XEvent *)xev, key, sizeof(key), &keysim, NULL);

Are you sure this is what you have in your program? It shouldn't even
compile since `KeySim' is not a valid type -- at least not a valid X
type.

switch(keysim){

case 'z': do_rotation();

Assuming this is just a typo, you also should not be testing on
`keysim'. `keysim' is an XID and is not an ASCII character.

You want to test on

switch ( key[0] ) {

...

key[0] will be the first character in the key[] array and shold be
what you want.

Refer to the manual page for XLookupString() for full details on use
of this function. You may also wish to look at the first volume of
the O'Reilly series on X programming -- I believe there's a discussion
of the use of XLookupString() there.

spl

_________________________________________________
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/