---
name: "SDL_MouseButtonEvent"
section: "3"
platform: "linux"
package: "libsdl1.2-dev"
version: "1.2.15+dfsg2-8"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_MouseButtonEvent"
---

# SDL\_MouseButtonEvent(3)

Mouse button event structure

## NAME

SDL\_MouseButtonEvent - Mouse button event structure

## STRUCTURE DEFINITION

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

## STRUCTURE DATA

- **type**

  **SDL\_MOUSEBUTTONDOWN** or **SDL\_MOUSEBUTTONUP**

- **button**

  The mouse button index (SDL\_BUTTON\_LEFT, SDL\_BUTTON\_MIDDLE, SDL\_BUTTON\_RIGHT)

- **state**

  **SDL\_PRESSED** or **SDL\_RELEASED**

- **x**, **y**

  The X/Y coordinates of the mouse at press/release time

## DESCRIPTION

**SDL\_MouseButtonEvent** is a member of the **SDL\_Event** union and is used when an event of type **SDL\_MOUSEBUTTONDOWN** or **SDL\_MOUSEBUTTONUP** is reported.

When a mouse button press or release is detected then number of the button pressed (from 1 to 255, with 1 usually being the left button and 2 the right) is placed into **button**, the position of the mouse when this event occured is stored in the **x** and the **y** fields. Like **SDL\_KeyboardEvent**, information on whether the event was a press or a release event is stored in both the **type** and **state** fields, but this should be obvious.

## SEE ALSO

**SDL\_Event**, **SDL\_MouseMotionEvent**
