Next: , Previous: , Up: Interfacing with the mouse   [Contents][Index]


4.12.1 The basics of the mouse

Before you do anything else, the events you want to receive have to be enabled with mousemask. You pass it a bit mask of events you would like to listen. By default, all the events are turned off. The bit mask ALL_MOUSE_EVENTS can be used to get all the events.

For current technology, the following events are of use.

NameDescription
BUTTON1_PRESSEDmouse button 1 down
BUTTON1_RELEASEDmouse button 1 up
BUTTON1_CLICKEDmouse button 1 clicked
BUTTON1_DOUBLE_CLICKEDmouse button 1 double clicked
BUTTON2_PRESSEDmouse button 2 down
BUTTON2_RELEASEDmouse button 2 up
BUTTON2_CLICKEDmouse button 2 clicked
BUTTON2_DOUBLE_CLICKEDmouse button 2 double clicked
BUTTON_SHIFTshift was down during button state change
BUTTON_CTRLcontrol was down during button state change
BUTTON_ALTalt was down during button state change
ALL_MOUSE_EVENTSreport all button state changes
REPORT_MOUSE_POSITIONreport mouse movement

There similar constants for mouse button #3 and #4.

There are some important things to note.

  1. Mouse buttons 1, 2, and 3 may be right, center, and left respectively, instead of right, left, and center.
  2. The BUTTON_SHIFT, BUTTON_ALT, and BUTTON_CTRL codes will probably not work, as they will probably be intercepted by the window manager.
  3. The mouse driver will not send both a click/release pair and a pressed message.