Mouse Double Click event

Hi all,
I am trying to handle mouse double click event.
I read in the docs there is a “clicks” field in SDL_MouseButtonEvent struct, which is supposed to be ‘1’ for single click or ‘2’ for double click event.
I get the mouse event (SDL_MOUSEBUTTONDOWN) correctly, but the “clicks” field has wrong values, like ‘120’, ‘240’, etc. (just as if this variable has not been initialized or so…)

Is this field actually working on SDL 2.0.2? Did I miss anything?
(I am using SDL 2.0.2 on Windows7 and VC2008)

Thanks!

The clicks field is supped to return 1, 2, etc… And works correctly on OS X. And it?s being handled completely platform independently so it should behave the same on all platforms. I would check to make sure you don?t have any ?bleedhtrough? in your switch statement (e.g. having say SDL_MOUSEWHEEL fall through into the SDL_MOUSEBUTTONDOWN/SDL_MOUSEBUTTONUP). As you can get ?odd? looking values if you are accessing the button event struct for a non-button event.

I would suggest compiling the testwm2 ?test? application from the SDL2 source and running it like so.

testwm2.exe ?info event

then it?ll spit copious output to stdout for every event handled… If the values are messed up there (e.g. jumping from 120 to 240) then there is definitely a bug in SDL2.

Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc
317-674-3296On Mar 13, 2014, at 7:29 PM, jmenossi wrote:

Hi all,
I am trying to handle mouse double click event.
I read in the docs there is a “clicks” field in SDL_MouseButtonEvent struct, which is supposed to be ‘1’ for single click or ‘2’ for double click event.
I get the mouse event (SDL_MOUSEBUTTONDOWN) correctly, but the “clicks” field has wrong values, like ‘120’, ‘240’, etc. (just as if this variable has not been initialized or so…)

Is this field actually working on SDL 2.0.2? Did I miss anything?
(I am using SDL 2.0.2 on Windows7 and VC2008)

Thanks!


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

then it?ll spit copious output to stdout for every event handled… If
the values are messed up there (e.g. jumping from 120 to 240) then there
is definitely a bug in SDL2.

Edward is probably right: if it’s jumping from 120 to 240, you’re
probably getting mousewheel data.

–ryan.

Hi Edward, and thanks for your reply :slight_smile:

I think this issue had nothing to do with mousewheel events… I checked my switch statement and it was correct.
Maybe it was not well explained, because I didn’t want to say that the “clicks” value was jumping through 120 to 240… The “clicks” value could be 120, or 170, or anything, but it was always the same value.

Anyway, it was most likely a bug in SDL, because I have updated to the new 2.0.3 version and it works right now.

Thanks!

[quote=“urkle”]The clicks field is supped to return 1, 2, etc… And works correctly on OS X. And it?s being handled completely platform independently so it should behave the same on all platforms. I would check to make sure you don?t have any ?bleedhtrough? in your switch statement (e.g. having say SDL_MOUSEWHEEL fall through into the SDL_MOUSEBUTTONDOWN/SDL_MOUSEBUTTONUP). As you can get ?odd? looking values if you are accessing the button event struct for a non-button event.

I would suggest compiling the testwm2 ?test? application from the SDL2 source and running it like so.

testwm2.exe ?info event

then it?ll spit copious output to stdout for every event handled… If the values are messed up there (e.g. jumping from 120 to 240) then there is definitely a bug in SDL2.

Edward Rudd
OutOfOrder.cc (http://OutOfOrder.cc)
Skype: outoforder_cc
317-674-3296

I’m observing exactly the same problem in 2.0.2 and I’m quite sure it’s not a switch case bleed-through. I’m going to update to 2.0.3 when I have a chance so I’ll report back if it’s still observed there (although it sounds like it’s done the trick for jmenossi).

I’m happy to report that SDL 2.0.3 has resolved this issue for me.