Event issues on Mac

I wrote several basic SDL2 tutorials a couple of years ago. I’ve had several people claim that the code didn’t work on a Mac. This one for example:

You can see from the comments at the bottom what the issues reported are. Someone also suggests changing the way events are being processed.

I don’t have a Mac and haven’t been able to investigate these issues. Does anyone have any insight into why these problems occur and how to solve them?------------------------
Daniel D’Agostino

Yeah, the suggestion is to use while(SDL_PollEvent(&event)) instead of
SDL_WaitEvent. Have you tried that?

Jonny DOn Sunday, November 8, 2015, dandago wrote:

I wrote several basic SDL2 tutorials a couple of years ago. I’ve had
several people claim that the code didn’t work on a Mac. This one for
example:
http://programmersranch.blogspot.com.mt/2014/02/sdl2-pixel-drawing.html

You can see from the comments at the bottom what the issues reported are.
Someone also suggests changing the way events are being processed.

I don’t have a Mac and haven’t been able to investigate these issues. Does
anyone have any insight into why these problems occur and how to solve them?


Daniel D’Agostino
http://www.programmersranch.com/

No, because the particular use case is input-driven and SDL_WaitEvent() makes perfect sense.

Does this mean SDL_WaitEvent() doesn’t work on Mac, and I always need to use SDL_PollEvent()?------------------------
Daniel D’Agostino

that comment is from 2014, are you sure this is still an issue? In the past I too have had the problem with SDL not dispatching the SDL_QUIT event on Mac OS X; I had to work around it in my application code by implementing applicationShouldTerminate in my app delegate and manually creating the SDL_QUIT event and queuing it with SDL_PushEvent.

No idea about the other issue with nothing being drawn. I do know that mac trackpads send a mix of touch events and mouse events. If the commenters notion of “clicking” is just taping the trackpad then its not going to hit the mouse down. the mousemotion events could not be being sent because it is instead sending touch events too.

I don’t know; as I said I don’t have a Mac. I was hoping someone could shed some light on whether this is a bug in SDL2 or I’m doing something wrong. It may well be a bug that’s been fixed, but I can’t check it myself.------------------------
Daniel D’Agostino

I just tested that tutorial (
http://programmersranch.blogspot.com.mt/2014/02/sdl2-pixel-drawing.html )
with SDL2 hg, on OSX 10.11.1, and it works fine for me. I can paint by
clicking the laptop’s trackpad. (The only things I changed were the
new/delete to malloc/free because I was running it inside the
SDLTest.xcodeproj, and didn’t want to bother configuring it for c++.)

The process also exits when I close the window, as expected.

Cheers,
EricOn Tue, Nov 10, 2015 at 10:58 AM, dandago wrote:

I don’t know; as I said I don’t have a Mac. I was hoping someone could
shed some light on whether this is a bug in SDL2 or I’m doing something
wrong. It may well be a bug that’s been fixed, but I can’t check it myself.


Daniel D’Agostino
http://gigi.nullneuron.net/gigilabs/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Great, thanks for checking.------------------------
Daniel D’Agostino