XForms: Button help - callback too late !!

Richard Kent (kent@hydra.dra.hmg.gb)
Thu, 22 May 1997 10:35:41 +0100

To subscribers of the xforms list from "Richard Kent" <kent@hydra.dra.hmg.gb> :

Hi all,

I have some "strange" code I would like to correct and hope that someone out
there can answer my question :-

I have a button which controls a system global. It is an on/off kind of setting
so when the button is switched on, the system setting is switched on. When the
button is switched off the system setting is switched off. So far so good...

I also have an idle callback which is constantly updating this button from the
system setting. This way my program can both monitor and control the system
setting.

The problem is, the xforms callback is only called when the physical mouse
button is released. Thus, nine times out of ten it happens that :-

(The system setting and button are both switched off)

1/. The user physically pushes the mouse button down on the button,
turning it on (the light comes on).
2/. Meanwhile the system updates the button, switching it off (the
light goes off).
3/. The user releases the mouse button, the callback is called,
checks the button, finds that it is off and sets the global off
(ie no change - wrong - the system global stays off)

What I need is for the button callback to be called when the user initially
pushes the mouse button down, not when it is released. I have tried all the
different types of button (push, in/out, etc) but they all appear to call the
callback upon mouse release.

My current "hack" is to have two buttons. An invisible button which the user
controls lying directly on top of an inactive but visible button which the
system controls. This way there is no interference between the two. The system
updating the visible button doesn't reset the invisible button which the user
is interacting with.

I would, however, like to get rid of this hack. Is there a better way to do
this ? Would some form of pre-emptive handler solve the problem better or is
this just as much trouble ? Would it not be wise to have a new button type
which calls its callbacks on mouse press, not mouse release ?

Cheers for any help,

TicH

------------------------------------------------------------------------
| Name - Richard Kent |
| EMail - kent@hydra.dra.hmg.gb |
| Plan - All work and no play.....hi ho, hi ho |
------------------------------------------------------------------------

------------------------------------------------------------------------
| Name - Richard Kent |
| EMail - kent@hydra.dra.hmg.gb |
| Plan - All work and no play.....hi ho, hi ho |
------------------------------------------------------------------------

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