SDL_MouseButtonEvent(3)

✨ SDL_MouseButtonEvent ✨

okay bestie, welcome to the SDL_MouseButtonEvent(3) page from the SDL API Reference πŸ’– this one's all about the lil struct that tells you when someone clicked a mouse button, no cap πŸ–±οΈβœ¨


🌸 NAME 🌸

SDL_MouseButtonEvent β€” the mouse button event structure, aka the glow-up notification you get when a click happens πŸ’…


πŸŽ€ STRUCTURE DEFINITION πŸŽ€

here's the whole fit, literally:

typedef struct{
  Uint8 type;
  Uint8 button;
  Uint8 state;
  Uint16 x, y;
} SDL_MouseButtonEvent;

that's it. five fields. iconic. πŸ‘‘


πŸ¦‹ STRUCTURE DATA πŸ¦‹

okay so let's go field by field, main character by main character:

  • type β€” either SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP 🫢 this is the vibe check on whether it's a press or a release.
  • button β€” the mouse button index, and the classics are SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, and SDL_BUTTON_RIGHT πŸ–±οΈ
  • state β€” SDL_PRESSED or SDL_RELEASED πŸ’…
  • x, y β€” the X/Y coordinates of the mouse at press/release time πŸ“ fr fr, it snaps the exact spot.

πŸ’– DESCRIPTION πŸ’–

so SDL_MouseButtonEvent is a member of the SDL_Event union, and it's the one that shows up when an event of type SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP gets reported ✨

when a mouse button press or release is detected, the number of the button pressed goes into button β€” that's a range from 1 to 255, and lowkey, 1 is usually the left button and 2 the right 🌈 then the position of the mouse when this event occured gets stored in the x and the y fields πŸ“ like, it's giving coordinates, periodt.

and just like SDL_KeyboardEvent, the info on whether the event was a press or a release is stored in both the type and state fields πŸ‘€ which, yeah, is redundant but honestly it should be obvious bestie 😭


πŸ”₯ SEE ALSO πŸ”₯

  • SDL_Event
  • SDL_MouseMotionEvent

go read those next, iykyk πŸ§šπŸ’œ


k that's the whole page, love u, go click some stuff πŸ’– and just so u know, this masterpiece is brought to you by SDL, dated Tue 11 Sep 2001, 22:59 β€” vintage but slaying 🌟 bye bestie!! πŸŽ€πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from