Re: Keys handler

Steve Lamont (
Tue, 26 Nov 96 07:08:31 PST

To subscribers of the xforms list from (Steve Lamont) :

> > You also need to tell XForms to set the event mask with
> > fl_addto_selected_xevent() (or the synonymous fl_add_selected_xevent()).
> This means that using the "keycode" member of XKeyEvent and this Xform
> function I can register only that keys on the keyboard that generates a
> KeyPress (or KeyRelease) events ?

I'm not sure I understand your question.

According to the X documentation, an KeyPressedEvent or
KeyReleasedEvent is "[g]enerated for all keys, even those mapped to
modifier keys such as Shift or Control." (O'Reilly & Associates, Inc.,
_The X Window System in a Nutshell_, ISBN 1-56592-017-1)

This means you're going to get all keystrokes (Press or Release,
depending upon which you've registered). You can then use whatever
mechanism you wish to select particular keycodes using the keycode
member of the XKeyEvent structure. I don't know offhand whether
there's a way to filter the keystrokes at a lower level.

You'd register your interest in and handle the KeyPress event as follows

FL_OBJECT *canvas;


fl_addto_selected_xevent( FL_ObjWin( canvas ), KeyPressMask );
fl_add_canvas_handler( canvas, KeyPress, key_press_handler, data );


int key_press_handler( FL_OBJECT *obj, Window window,
int win_width, int win_height,
XEvent *xevent, void *data )


XKeyPressEvent *key_press_event = ( XKeyPressEvent *) xevent;

if ( key_press_event->keycode == XK_your_favorite_keycode ) {


I hope this is responsive to your question. If not, perhaps you can
explain in more detail what you're trying to do.

To unsubscribe, send the message "unsubscribe" to or see