[SDL] Re: Question about ignoring mouse events

Román Gorojovsky rgorojovsky at gmail.com
Wed Nov 16 05:26:11 PST 2005


Yes, thank you, that *almost* worked.

But if you do "while (SDL_PollEvent(&event))" the loop won't even
start, because usually at that point you don't have any event.  So I
did

while (1) {
    if (SDL_PollEvent(&event))
        {/*everything*/}
}

and that did work.  Thanks a lot.  I'll be back!!!

On 11/16/05, Ryan C. Gordon <icculus at icculus.org> wrote:
>
>  >      while (1) {
>  >              SDL_PollEvent(&event);
>  >              switch (event.type) {
>
> You _need_ to check the return value from SDL_PollEvent!
>
> What is happening is you are getting a legitimate mousebuttondown event,
> and then the next call to SDL_PollEvent() is reporting that there aren't
> any more events, but you are ignoring this and looking at the data from
> the previous event, which is still in the "event" object from the
> previous call.
>
> It's best to do "while (SDL_PollEvent(&event))", handle all queued
> events, and then do whatever else you want the program to do, then
> repeat it again next frame.
>
> --ryan.
>
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>


--
Román


More information about the SDL mailing list