Next Previous Contents

17. Mouse Functions

17.1 gpm_disable_mouse

Synopsis

Disable support for the GPM mouse

Usage

gpm_disable_mouse ()

Description

The gpm_disable_mouse function may be used to inactivate support for the GPM mouse.

Notes

This function may not be available on all systems.

See Also

mouse_get_event_info

17.2 mouse_get_event_info

Synopsis

mouse_get_event_info

Usage

(x, y, state) = mouse_get_event_info ();

Description

This function returns the position of the last processed mouse event, and the state of the mouse buttons and shift keys before the event.

x and y represent the column and row, respectively, where the event took place. They are measured with relative to the top left corner of the editor's display.

state is a bitmapped integer whose bits are defined as follows:

         1  Left button pressed
         2  Middle button pressed
         4  Right button pressed
         8  Shift key pressed
        16  Ctrl key pressed
Other information such as the button that triggered the event is available when the mouse handler is called. As a result, this information is not returned by mouse_get_event_info.
See Also

mouse_set_default_hook, set_buffer_hook.

17.3 mouse_map_buttons

Synopsis

mouse_map_buttons

Usage

Void mouse_map_buttons (Integer x, Integer y);

Description

This function may be used to map one mouse button to another. The button represented by x will appear as y.

17.4 mouse_set_current_window

Synopsis

mouse_set_current_window

Usage

Void mouse_set_current_window ();

Description

Use of this function results in changing windows to the window that was current at the time of the mouse event.

See Also

mouse_set_default_hook

17.5 mouse_set_default_hook

Synopsis

mouse_set_default_hook

Usage

Void set_default_mouse_hook (String name, String fun);

Description

This function associates a slang function fun with the mouse event specified by name. The first parameter name must be one of the following:

            "mouse_up"          "mouse_status_up"
            "mouse_down"        "mouse_status_down"
            "mouse_drag"        "mouse_status_drag"
            "mouse_2click"      "mouse_status_2click"
            "mouse_3click"      "mouse_status_3click"
The meaning of these names should be obvious. The second parameter, fun must be defined as
           define fun (line, column, btn, shift)
and it must return an integer. The parameters line and column correspond to the line and column numbers in the buffer where the event took place. btn is an integer that corresonds to the button triggering the event. It can take on values 1, 2, and 4 corresponding to the left, middle, and right buttons, respectively. shift can take on values 0, 1, or 2 where 0 indicates that no modifier key was pressed, 1 indicates that the SHIFT key was pressed, and 2 indicates that the CTRL key was pressed. For more detailed information about the modifier keys, use the function mouse_get_event_info.

When the hook is called, the editor will automatically change to the window where the event occured. The return value of the hook is used to dictate whether or not hook handled the event or whether the editor should switch back to the window prior to the event. Specifically, the return value is interpreted as follows:

          -1     Event not handled, pass to default hook.
           0     Event handled, return active window prior to event
           1     Event handled, stay in current window.
See Also

mouse_get_event_info, mouse_set_current_window, set_buffer_hook


Next Previous Contents