Re: XForms: Creating Object

Steve Lamont (spl@szechuan.ucsd.edu)
Thu, 11 Jun 98 07:21:44 PDT

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

> In the chapter in the manual on EVENTS it says under the FL_PUSH and
> FL_RELEASE statements that the key parameter returns 1=leftmouse, 2=
> middlemouse, 3 = rightmouse. This is definitely the case in version 0.86
> but NOT in version 0.88. ...

You are correct -- I didn't read the manual correctly and got
sidetracked.

>From my testing I think that what's happening is that there is some
sort of collison between real events and synthetic events generated by
XForms's internal timing and the real event gets interpreted
correctly. TC?

Although in my tests, interpreting the XButtonReleasedEvent seemed to
work correctly, I guess that it might not necessarily always do so.

In this instance, the following workaround should suffice:

static int handle( FL_OBJECT *obj, int event,
FL_Coord mx, FL_Coord my,
int key, void* xev)

{

static int button_pressed = -1;

switch ( event ) {

case FL_PUSH: {

button_pressed = key;
do_button_pressed_stuff( button_pressed, ... );
break;

}
case FL_RELEASE: {

if ( button_pressed != -1 )
do_button_released_stuff( button_pressed, ... );
button_pressed = -1;
break;

}
[...]

It's a kluge but it seems to work in all the cases I've tried. I
suppose if you're truly paranoid, you might use fl_get_mouse() or one
of its ilk to fetch the keymask for parsing.

You could also put this flag in your object's SPEC structure if you
didn't want to use the static variable, although I can't conjure up a
scenario where this would be absolutely necessary.

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/