Next: Clipping, Previous: Color Handling, Up: Part IV Drawing Objects [Contents][Index]

### 28.3 Mouse Handling

The coordinate system used corresponds directly to that of the screen. But object coordinates are relative to the upper-left corner of the form the object belongs to.

To obtain the position of the mouse relative to a certain form or window, use the routines

    Window fl_get_form_mouse(FL_FORM *form, FL_Coord *x, FL_Coord *y,
                             unsigned *keymask)
    Window fl_get_win_mouse(Window win, FL_Coord *x, FL_Coord *y,
                            unsigned *keymask);

The functions return the ID of the window the mouse is in. Upon return `x` and `y` are set to the mouse position relative to the form or window and `keymask` contains information on modifier keys (same as the the corresponding `XQueryPointer()` argument).

A similar routine exists that can be used to obtain the mouse location relative to the root window

    Window fl_get_mouse(FL_Coord *x, FL_Coord *y, unsigned *keymask);

The function returns the ID of the window the mouse is in.

To move the mouse to a specific location relative to the root window, use the following routine

    void fl_set_mouse(FL_Coord x, FL_Coord y);

Use this function sparingly, it can be extremely annoying for the user if the mouse position is changed by a program.