is_mouse_pressed variable stores whether or not a mouse button is currently being pressed.
1# click within the image and press 2# the left and right mouse buttons to 3# change the value of the rectangle 4def draw(): 5 if py5.is_mouse_pressed and py5.mouse_button == py5.LEFT: 6 py5.fill(0) 7 elif py5.is_mouse_pressed and py5.mouse_button == py5.RIGHT: 8 py5.fill(255) 9 else: 10 py5.fill(126) 11 12 py5.rect(25, 25, 50, 50)
is_mouse_pressed variable stores whether or not a mouse button is currently being pressed. The value is
True when any mouse button is pressed, and
False if no button is pressed. The mouse_button variable (see the related reference entry) can be used to determine which button has been pressed.
Updated on September 11, 2021 16:51:34pm UTC