As far as I can tell, when an event is polled, that is basically it’s end state, the event doesn’t have to be de-allocated/freed later, it just disappears at the end of the game loop.
So I don’t think there’s any side-effects of consuming an event in this manner:
void guiTextBox::eventHandler(SDL_Event * ev)
{
switch(ev->type)
{
case SDL_TEXTINPUT:
// confirm correct window if multiple
// confirm item has focus
// grab the text etc.
// Now, consume the event:
SDL_Zero(*ev);
break;
case SDL_MOUSEDOWN:
// here's the faster option, SDL_FIRSTEVENT is ignored everywhere.
// so we don't have to reset all the values, just the type.
ev->type = SDL_FIRSTEVENT;
break;
}
}
Is there anything that I’m missing, or are these both acceptable methods?
Technically if anyone uses SDL_LogEvent(SDL_Event *event) after the event handler, it will log the SDL_FIRSTEVENT, and append “THIS IS PROBABLY A BUG!” at the end of that line, but that’s the only issue that I could find, and I don’t count that as a side-effect since it is intentional.