XForms: KeyPress problems

Miguel Monteiro de Sousa Frade (mfrade@ener1000.dee.uc.pt)
Tue, 21 Apr 1998 13:14:05 +0100 (WEST)

# To subscribers of the xforms list from Miguel Monteiro de Sousa Frade <mfrade@ener1000.dee.uc.pt> :

Hi everyone,
I'm working with Xforms and a MesaGL canvas. In my program I need to read
the keyboard to do zoom and rotations of the drawings. My problems begin
when I move the mouse away from the canvas, some times it just ignore the
pressed keys and do nothing, as expected, or it does a "segmentation fault
core dump". This problem is intermittent and I have no ideas what could be
causing this behaviour. Any suggestions?

When the mouse is inside of the canvas the handler for KeyPress works, but
not exactly as I want. When I press one key, such as "z" for a rotation
about the Z-axis, the canvas must be redraw each time the key is pressed,
that is what happens. But if I stay pressing a key for a while some buffer
(which I can't or don't know how to control) keeps the keys that where
pressed, because of the time it takes to redraw the scene. And the speed
of redrawing reduces after the key is depressed. Besides, when I press for
a while keys that should be ignored (do nothing) the entire program is
staled until those keys are dispatch from the buffer (and this operation
can take a few seconds depending of time I stay pressing). What I'd like
to do is: "Do function while key pressed"
How can I achieve this? The Mesa library has one function to associate the
KeyPress event to a function that works as I want,
glutKeyboardFunc(function_name), but this function can't be called in
Xforms.

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);

switch(keysim){

case 'z': do_rotation();

...

}

}

Note: the size of the array key[] don't have any influence in behaviour of
my program when I press keys for a some time.

Best regards,
Miguel M. S. Frade

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