Re: XForms: Shortcut key problem

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 26 Aug 98 07:14:52 PDT

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

> And I want to make a key shortcut to a menu function...
>
> ok, and the manual says that exists a function
> fl_set_menu_shortcut (ob, int id, char *);

You need to also add a shortcut to the menu itself with
fl_set_object_shortcut() (or allow `fdesign' to do it for you by
setting the shortcut field in the Attributes dialog for the menu).
In this manner you can first pop the menu with the menu shortcut, then
select the menu item with the menu shortcut.

If you don't like to deal with having to deal with multiple
keypresses, the alternative is to set a raw callback with
fl_register_raw_callback() which will see any event before it is
passed to the XForms internal event handlers. Using it would look
something like

fl_register_raw_callback( fd_my_form->my_form,
KeyPressMask,
key_handler );

[...]

int key_handler( FL_FORM *form, void *xevent )

{

int preempt;
XEvent *event = ( XEvent *) xevent;

if ( event->type == KeyPress ) {

XKeyPressedEvent *key_event = ( XKeyPressedEvent *) xevent;
KeySym keysym =
XKeycodeToKeysym( fl_get_display(),
key_event->keycode,
0 );
FD_my_form *fd_my_form = form->fdui;

switch ( keysym ) {

case XK_A: { /* Handles 'A' key */

do_something( ... );
break;

}

[...]

}
preempt = FL_PREEMPT;

} else
preempt = !FL_PREEMPT;

return preempt;

}

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/