C Question

How to use SDL_MOUSEBUTTONDOWN correctly?

I'm trying to use x and y coordinates from mouse for a game, but i can not get the coordinates.

This is the event i've been reading:

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


I need something like:

if(SDL_MouseButtonEvent.x >= 100)
{
//do something
}


I think the sintax is very different because i saw some examples using SDL_MOUSEBUTTONDOWN.

EDIT

I apologize, know this question might not be clear, but Peter's answer was just what I needed, thanks for your time.

Answer

If you want to intercept a click in an specific area first you need to be polling the events and check for a SDL_MouseButtonEvent.

while(running)
{
    while(SDL_PollEvent(&event)) // check to see if an event has happened
    {
        switch(event.type)
        {
            case SDL_QUIT:
                running = false;
                break;
            case SDL_MOUSEBUTTONDOWN: // if the event is mouse click
                if(event.mouse.x >= 100)  // check if it is in the desired area
                {
                    //do something    
                }
        }
    }
}

I hope this helps.