Mouse Click Event Problum

Ok here is the problem I have. I’m trying to make a simple button
class for my game and I can’t seem to get the mouse event to work
right. All I want is when I click the mouse for it to check and see if
that spot is where the click occurred was with in a buttons area. Now
to me that seemed really simple I coded it all up in SDL and it seems
to work but only a little bit. I’m VERY confused!!! Sometimes when I
click the button it reacts and other times it doesn’t. It is very
sporadic. I started printing out the Mouse Coordinates when it clicked
and for the most part it changes but sometimes it seem the position
doesn’t update. This usually happens when I click outside the button
then click inside the button. The position won’t change till I move the
mouse dramatically inside the button area. The same thing happens
vis-versa the button will be clicked when I’m out of the the button.
I’m sure my bounds checking is correct I’m checked all of that. Please
help… my event code is below I’ve tried a couple of ways and hey are
both there:

while (done != 1)
     {
         int x, y;
         SDL_PumpEvents();
             if(SDL_GetMouseState(&x, &y)&SDL_BUTTON(1))
             {
                 fprintf(stderr, "Mouse X: %d  Y: %d \n",x,y);
                 temp = myGUI.checkButtons(screen,x,y);
             }

         if(temp != NOTHING)
                 {
                     fprintf(stderr, "Action Happened!!\n");
                     if(temp == ENDGAME)
                             quit_Game();

                     temp = NOTHING;
                 }

         myGUI.drawSplash(screen);
         SDL_Flip(screen);
     }

/* Clean up the SDL library */
quit_Game();

}

And the next one:

while (done != 1)
     {
        while(SDL_PollEvent(&event))
         {
             switch(event.type)
             {
                 case SDL_KEYDOWN:
                     switch(event.key.keysym.sym)
                     {
                         case SDLK_SPACE:
                             break;
                         case SDLK_ESCAPE:
                             done = 1;
                             break;
                         default:
                             break;
                     }
                     break;

                 case SDL_MOUSEBUTTONDOWN:
                         count++;
                         temp = myGUI.checkButtons(screen,event);
                     break;

             }
		  if(temp != NOTHING)
                 {
                     fprintf(stderr, "Action Happened!!\n");
                     if(temp == ENDGAME)
                             quit_Game();

                     temp = NOTHING;
                 }

         }

         myGUI.drawSplash(screen);
         SDL_Flip(screen);
     }

/* Clean up the SDL library */
quit_Game();

}
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: text/enriched
Size: 3974 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030723/6370ca0a/attachment.bin