SDL2 - On focus-gain first click detection


Hi everyone.

I’m a video game student trying to do a complete UI library.
I have noticed that SDL doesn’t detect a click made in the middle of the window at the same time the window gains focus (SDL_WINDOWEVENT_FOCUS_GAINED) is thrown, but there is no “Mouse Down” event.

Is there a way to fix / fake this? I’ve tried using PushEvent(), which kinda does the job, but SDL doesnt detect the “Mouse Up” after that one.

Thanks for all answers!


You can call SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, “1”) to get the behaviour you’re looking for, I think.


“A hint that specifies if mouse click events are sent when clicking to focus an SDL window.

It looks exactly what i am looking for, i will test it tomorrow.
Thanks for the quick reply!


Problem solved, thank you!