Concept

Mouse Events in Pygame

There are three types of mouse events in pygame: 1. MOUSEBUTTONUP, for when a mouse's button is released. 2. MOUSEBUTTONDOWN, for when a mouse's button is pressed. 3. MOUSEMOTION, for when the mouse moves across the screen. Each EventType object generated has a number of attributes which are listed below.

MOUSEMOTION:

  • buttons: a tuple containing the buttons on the mouse being pressed
  • pos: the xy coordinates of the cursor after movement
  • rel: the xy coordinates of the post-movement position relative to the previous position (AKA the distance)

MOSUEBUTTONDOWN and MOUSEBUTTONUP:

  • button: an int representing the button being pressed. 1 for left button, 2 for mosue wheel, 3 for right button, 4 for scrolling up, and 5 for scrolling down.
  • pos: the xy coordinates of the cursor when the button was pressed

0

1

Updated 2021-07-28

Tags

Python Programming Language

Data Science