XForms: ObjWasClicked() was "Focus on a choice list?"

Frank Stefani (EAD-Frank.Stefani@t-online.de)
Wed, 25 Jun 1997 10:25:28 +0200

To subscribers of the xforms list from EAD-Frank.Stefani@t-online.de (Frank Stefani) :

> > how can I determine, if the mouse currently clicked on the
> > pulldown botton of a choice list and the list is now opened?
>
> I'm not certain I parsed your question correctly but I think the
> answer is you can't because the interaction within a Choice object is
> handled within XForms and you don't get notified of it until the
> choice is actually made.
>
> You might be able to get some sort of pre-notification with a
> pre-handler but I haven't ever tried (or wanted to try) to do such a
> thing so I'm not sure at what point the pre-handler is called. I
> suspect it will take a little experimentation.
^^^^^^^^^^^^^^^^^^^^^^^^

Well, that's what I did. Look ...

Due to the fact that I'm already using a raw event callback for
the form, I enhanced it in the following manner to discover whether
a particular object was clicked (see ENHANCEMENT below):

int
raw_event_cb(FL_FORM *form, void *xev)
{
XKeyEvent *xkey;
XButtonEvent *xbutton;
FL_OBJECT *some_obj;
/* ... */

switch ( ((XKeyEvent *)xev)->type ) {
case KeyPress:
xkey = (XKeyEvent *)xev;
keysym = XKeycodeToKeysym(xkey->display, xkey->keycode, 0);
switch ( keysym ) {
case XK_Return: /* process Return key */
break;
case XK_F1: /* process F1 key */
break;
/* ... other keys ...*/
}
break;

case ButtonPress:
xbutton = (XButtonEvent*)xev;
switch ( xbutton->button ) {
case 1: /* Process button 1 */
/* ENHANCEMENT: */
if ( ObjWasClicked(some_obj, xbutton) ) {
/* process 'some_obj' related stuff */
}
break;
case 2: /* Process button 2 */
break;
/* ... other buttons ... */
}
}
return(/* FL_PREEMPT or !FL_PREEMPT as needed */);
}

And ObjWasClicked(...) is a macro defined as

/* Was object 'O' currently clicked? */
#define ObjWasClicked(O,Xev)
(Xev->x>=O->x&&Xev->x<=O->x+O->w&&Xev->y>=O->y&&Xev->y<=O->y+O->h)

Any comments on this? Better idea? 'Clean' implementation with
pure XForms?

Greetings,
Frank.

-- 
---------------------------------------------------------------
     _/_/_/_/     _/_/     _/_/_/    EAD-Systeme GmbH
    _/          _/  _/    _/    _/   Nachfeldstr. 4
   _/_/_/     _/    _/   _/     _/   D-82490 Farchant, Germany
  _/        _/_/_/_/_/  _/     _/    Phone: +49 8821 9623-0
 _/_/_/_/ _/        _/ _/_/_/_/      Fax: +49 8821 9623-20
---------------------------------------------------------------
Email: EAD-Frank.Stefani@t-online.de
---------------------------------------------------------------

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