pyglet.window.mouse

Mouse constants and utilities for pyglet.window.

class MouseStateHandler

Simple handler that tracks the state of buttons from the mouse. If a button is pressed then this handler holds a True value for it. If the window loses focus, all buttons will be reset to False in order to avoid a “sticky” button state.

For example:

>>> win = window.Window()
>>> mousebuttons = mouse.MouseStateHandler()
>>> win.push_handlers(mousebuttons)

# Hold down the "left" button...

>>> mousebuttons[mouse.LEFT]
True
>>> mousebuttons[mouse.RIGHT]
False
buttons_string(buttons)

Return a string describing a set of active mouse buttons.

Example:

>>> buttons_string(LEFT | RIGHT)
'LEFT|RIGHT'
Parameters:
buttons : int

Bitwise combination of mouse button constants.

Return type:

str

LEFT = 1

Constant for the left mouse button.

Meta hide-value:
 
MIDDLE = 2

Constant for the middle mouse button.

Meta hide-value:
 
MOUSE4 = 8

Constant for the mouse4 button.

Meta hide-value:
 
MOUSE5 = 16

Constant for the mouse5 button.

Meta hide-value:
 
RIGHT = 4

Constant for the right mouse button.

Meta hide-value: