MouseButtonEvent.button is a Button, not a ButtonMask. On the other hand, it is correct that MouseMotionEvent, GetRelativeMouseState, GetMouseState and GetGlobalMouseState all deal with ButtonMask.
The utility functions to convert between Button and ButtonMask mentioned in the example here was not committed: so I added them also since they sounded nice.
So the correct way to check for a right button in a MouseButtonEvent e
if e.Button == sdl.ButtonRight {...}
While for a MouseMotionEvent e it would be:
if e.State.Has(sdl.ButtonLeft) {...}
or
if e.State&sdl.ButtonMaskLeft != 0 {...}
MouseButtonEvent.button
is aButton
, not aButtonMask
. On the other hand, it is correct thatMouseMotionEvent
,GetRelativeMouseState
,GetMouseState
andGetGlobalMouseState
all deal withButtonMask
.The utility functions to convert between
Button
andButtonMask
mentioned in the example here was not committed: so I added them also since they sounded nice.So the correct way to check for a right button in a
MouseButtonEvent e
While for a
MouseMotionEvent e
it would be: