Re: XForms: which form the mouse is in?

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 12 Jan 98 07:07:59 PST

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

> I have a multi-form application and need to know programatically which
> form the mouse pointer is in at a given moment. I tried to use some
> XFORMS lib routines, but with no success. My platform is Solaris 2.5,
> XForms 0.86, 0.88.

How are you attempting to track the mouse? If you're using some sort
of callback you should generally have the form, the object, or an
XEvent as a parameter. XEvents contain the Window in which they're
generated and from that you can deterine the form with fl_win_to_form().

About the only callbacks that don't provide this sort of context are
the signal and timeout callbacks. Is this where you're having
problems?

My best workaround suggestion is to do something like:

FL_Coord x;
FL_Coord y;
unsigned mask;
Window window;
Window root;
Window parent;
Window *children;
unsigned int n_children;
FL_FORM *form;

/*
* Get the parent of the Form's Window, which the
* Window Manager has provided.
*/

window = fl_get_mouse( &x, &y, &mask );

/*
* Now fish up the child window. There should be only
* one.
*/

XQueryTree( fl_get_display(), window,
&root, &parent, &children, &n_children );

/*
* Find the Form;
*/

form = fl_win_to_form( children[0] );

/*
* Get that Good Housekeeping Seal of Approval.
*/

XFree( children );

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://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/