typedef void (*mousefn)(control c, int buttons, point xy);
void setmousedown(control c, mousefn fn); void setmousemove(control c, mousefn fn); void setmousedrag(control c, mousefn fn); void setmouseup(control c, mousefn fn); void setmouserepeat(control c, mousefn fn);
#define NoButton 0x0000 #define LeftButton 0x0001 #define MiddleButton 0x0002 #define RightButton 0x0004
The functions setmousedown, setmousemove, setmousedrag, setmouseup, setmouserepeat allow response to mouse events. They associate call-back functions with a control, so that when a certain kind of mouse events occurs, the relevent call-back function is called.
Each of the functions handles a different kind of mouse event:
Each of the call-backs are defined as mousefn. A mousefn has an integer argument buttons and a point xy. These refer to the mouse state.
If any of the mouse buttons are held down when the call-back is activated, the buttons parameter will be set to reflect the fact. It is a bit-field which is organised so that buttons&LeftButton is set when the left mouse button is down, buttons&MiddleButton corresponds to the middle mouse button and buttons&RightButton corresponds to the right mouse button. It will be zero if no buttons are held down. The point xy is the location of the mouse in local co-ordinates, relative to the control.