Py5MouseEvent.get_button()#

Identify the mouse button used in the event.

Examples#

 1def setup():
 2    py5.size(200, 200, py5.P2D)
 3    py5.rect_mode(py5.CENTER)
 4
 5
 6def draw():
 7    py5.square(py5.random(py5.width), py5.random(py5.height), 10)
 8
 9
10def mouse_clicked(e):
11    mouse_button = e.get_button()
12    if mouse_button == py5.LEFT:
13        py5.println('left mouse click')
14    elif mouse_button == py5.CENTER:
15        py5.println('center mouse click')
16    elif mouse_button == py5.RIGHT:
17        py5.println('right mouse click')

Description#

Identify the mouse button used in the event. This can be LEFT, CENTER, or RIGHT.

Underlying Processing method: getButton

Syntax#

get_button() -> int

Updated on April 27, 2022 10:44:51am UTC