# To subscribers of the xforms list from Angus Leeming <angus.leeming@btopenworld.com> :
On Wednesday 28 May 2003 3:30 am, Reed Riddle wrote:
> # To subscribers of the xforms list from "Reed Riddle" <drriddle@qwest.net>
> :
>
> Hi folks,
>
> I'm building an application with an interactive xyplot, and one of the
> things I do is allow the user to move from point to point in the plot
> with the arrow keys. This works just fine with a handler routine,
> except if the user holds the key down; when they do that, the selected
> point keeps moving after the key is released. I also allow the user to
> use the mouse for selecting points, but the people who will use this
> software are stubborn and want to hold the key down and scroll through
> the points. Damn them anyways... ;)
>
> So, what I need is something that will check if a key on the keyboard
> is released. If the key is released, then I want to ignore all the
> keyboard events in the queue. I am completely an X novice, so please
> don't tell me to flush the Xevent queue, it will be lost on me. :)
> The program is processing Xevents fast enough that I can just ignore
> the extra key presses; I just need a way to test if the key is pressed
> still before I do the operation.
>
> Thanks for any and all help!
>
> Reed
Hello Reed,
if you want notification from xforms about an XEvent of type KeyRelease
(xforms gives them the enum identifier FL_KEYRELEASE), then I'm afraid you
are entirely out of luck. xforms silently swallows them.
do_interaction (which processes the raw XEvents) hands KeyRelease events to
do_keyboard which in turn hands them to the main xforms event handler,
fl_handle_form (although it actually processes KeyRelease events incorrectly
since calling XmbLookupString on a KeyRelease event is undefined --- not that
that should matter in your case).
Thereafter, I'm afraid, the trail goes cold. FL_KEYRELEASE is simply not
handled at all in the fl_handle_form switch. You have absolutely no hope of
xforms telling you about it. Instead you will have to use something like:
fl_register_raw_callback(form, KeyReleaseMask, peek_event);
where
static int peek_event(FL_FORM * form, void * ev);
is a function you create to process the XEvent that has been cast to a void *:
static int peek_event(FL_FORM * form, void * ev) {
XEvent * xev = ev;
if (xev->type == KeyRelease) {
...
return 1;
}
return 0;
}
FWIW, I have a patch that fixes this bug in xforms but it is currently part of
a larger whole and I haven't tried to extract this little bit yet.
HTH,
Angus
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/
Development: http://savannah.nongnu.org/files/?group=xforms
This archive was generated by hypermail 2b29 : Wed May 28 2003 - 03:44:14 EDT