Pygame mouse events | Sololearn: Learn to code for FREE!

0

Pygame mouse events

how do you check for pygame's mouse events like dragging the mouse ?

6/9/2017 7:47:34 PM

khabz01

2 Answers

New Answer

+1

Check MOUSEBUTTONDOWN, MOUSEBUTTONUP, and MOUSEMOTION events in pygame. You would do something like this: # global flag dragging = False . . . if event.type == pygame.MOUSEBUTTONDOWN: dragging = True elif event.type == pygame.MOUSEBUTTONUP: dragging = False elif event.type == pygame.MOUSEMOTION: if dragging: # do something