0

How do I determine which exact mouse button (right, left, middle, etc.) is pressed? I'm using SDL. Here is the code that I have, which says if any mouse button is clicked or not:

            case SDL_MOUSEBUTTONDOWN:
              {
                Mouse_Pressed = event.button.clicks;
              } break;

            case SDL_MOUSEBUTTONUP:
              {
                Mouse_Pressed = 0;
              } break;
Philip
  • 13
  • 1
  • 4

1 Answers1

1

You can access that through the event button field.

case SDL_MOUSEBUTTONUP:
            switch ( ev.button.button ) {
                case SDL_BUTTON_LEFT:
                    break;
                case SDL_BUTTON_RIGHT:
                    break;
                case SDL_BUTTON_MIDDLE:
                    break;
                case SDL_BUTTON_X1:
                    break;
                case SDL_BUTTON_X2:
                    break;
            }

https://wiki.libsdl.org/SDL_MouseButtonEvent

ziptron
  • 211
  • 1
  • 6