I am having some issues handling double clicking in SDL_2. I have tried and tried different methods, but to no avail. When I output the return values of ev->button->clicks it seems to return random characters and numbers, and nothing upon a button click. If anyone could provide example code for handling double clicking, that would be great (or direct me to some). I have searched far and wide and can't seem to find an example that helps. I have checked SDL's documentation and can't seem to find any either. Thanks again.
For what it's worth, you're most likely not handling the event instance correctly if you're getting garbage. An SDL event is actually a union type of various events. To make sure you have a mouse button event, check ev->type for the values "SDL_MOUSEBUTTONDOWN" and "SDL_MOUSEBUTTONUP".
Sucks they don't have examples... would be really simple to add one.
Just looked, they do have examples... they just forgot to remove the "insert example here" section for some reason...
I want to say your right. I usually don't have a problem handling SDL_Events, but this one particularly is giving me issues. Below is what I've tried recently. I've tried a similar "if statement" approach that didn't work either.
Note that ev->button.clicks is an Uint8 which is the same as unsigned char so cout will output as if it was a character. To output the numerical value you should convert it to one of the bigger integer types before printing it.
I've just added the static cast. The output still shows a bunch or random numbers, usually 38, 41, 40, 112 something like that (when the mousebutton is pressed). Otherwise returns zero.
In that example, youll fetch mouse data from the event instance even though its outside of the block of code that checks whether or not its actually a mouse button event.
How does that even work...? If it's an out of date library that doesn't include the feature, why doesn't the compiler say something about it... i.e. shouldn't clicks be missing?
Honestly I was wondering the same thing, but the clicks field is still present in the code. I checked all the headers to insure that, but the output from what Peter gave me returned 2.0.1. Which is really odd. I am currently trying to update to 2.0.3, but now I am getting system crashes at compile time.
Fixed that crashing error, it required manual compilation, man I was behind on my SDL updates! Thanks for everyones help! The clicks field seems to be returning the correct values now!