cmu-cs-academy / desktop-cmu-graphics

BSD 3-Clause "New" or "Revised" License
15 stars 9 forks source link

Add support for an optional button parameter in mouse press, release, and drag #40

Closed austin-schick closed 1 year ago

austin-schick commented 1 year ago

What this PR does

onMousePress and onMouseRelease can now optionally take button, which is an integer representing the button that was pressed. onMouseDrag can optionally take buttons, which is a list of integers representing all pressed buttons.

def onMousePress(x, y, button):
    print('p', x, y, button)

def onMouseRelease(x, y, button):
    print('r', x, y, button)

def onMouseDrag(x, y, buttons):
    print('d', x, y, buttons)

This is a port of https://github.com/cmu-cs-academy/cs-academy/pull/4823

schmave commented 1 year ago

Looks good to me!

If you scroll the mouse wheel, onMousePress gets called with an interesting value for button that seems to indicate the direction and amount of the scroll. Partly this seems nice, for people who want to use it. But I think it's a bit surprising in bad way for most people. Maybe only call onMousePress if button is <= 2?