Click count and events |
Alvin Beach
Guest
|
Hello,
Is it expected/normal that when dealing with multiple clicks (double, triple, etc.) that a SDL_MouseButtonEvent (DOWN/UP) be generated for each intermediate click? For example, say I want to do something for a single click and something different for a double-click, I always receive two events when I perform a double-click: one for the first click and the other for the second click. This results in the single-click code being executed (not desired) and then the double-click code. I was expecting to only receive one event when a double-click occurs. Just curious if this is a bug or just a misunderstanding on my part. Alvin _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
Click count and events |
Jeffrey Carpenter
Guest
|
Alvin,
Hi. I do believe so (if my memory is serving me right!) that it is normal for this behavior to occur. You can use the clicks field of SDL_MouseButtonEvent in order to filter out the undesirable events: if( ev.type == SDL_MOUSEBUTTONDOWN && ev.button.clicks == 2 ) { // Execute action } Cheers, Jeffrey Carpenter On 2014/07/ 09, at 17:34, Alvin Beach wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Click count and events |
Click count and events |
Alvin Beach
Guest
|
On 09/07/14 20:14, Jonas Kulla wrote:
Yeah, that's how I was thinking it could be handled. Didn't make much sense to me either for that reason as well. Just wanted to be sure. Thanks. Cheers, Alvin _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: Click count and events |
Dominus
|
A year later and this behavior bites me :( We have this code in the iOS port of Exult
(see https://github.com/litchie/exult-ios/blob/master/gumps/iphone_gumps.cc#L250) And I can't fix the part
to differ better between single and double clicks. Can anyone help me? |
|||||||||||||||||||
|
Click count and events |
J. M. B. C.
Guest
|
You can count a single click as happened, until the timed delay for a double click chance has expired. That manner you know for sure if it is just a single click or an in middle double click click. Yes, there is, a double click click interval milliseconds value stored in some SDL variable.
Expection is to event.mouse.clicks care about that, and just ignore on event->mouse.down and event->mouse.up // if mouse down or up but click or else then click handling blah blah blah switch mouse->clicks {   case 1: single_click(); break;   case 2: double_click(); break; } If SDL does not take care of that then there is, or was, or should, an event->mouse.lastclickt and an SDL_GetClickInterval(). P.S.: You sure know better than me. El 15/10/2015 01:50, "Dominus" escribió:
|
|||||||||||||
|
Click count and events |
Jonny D
|
Here are 2 options when considering single vs. double clicks.
Most common: Make their functionality not interfere. You see this in a particular UI when single click means "select" and double click means "activate". Less common: Add a delay in processing clicks. You essentially wait to process clicks until you know that they are not part of a double-click (impossible to predict). This can make your UI less responsive. If you have to do it this way, then you might consider it a bug in your UI design. Jonny D On Thu, Oct 15, 2015 at 7:23 AM, J. M. B. C. wrote:
|
|||||||||||||||
|
Re: Click count and events |
Dominus
|
Thank you, I'll see if I can come up with something here. I'm mostly pulling my hair since everything I tried so far didn't work. But I might be able to proceed from these hints.
Dom
|
|||||||||||||||
|
Re: Click count and events |
Dominus
|
I'll have to take the less common way. Exult is an engine remake of a Dos game, so much use of mouse and shortcut keys. The port to iOS doesn't leave much choice but assigning bot single and double click (or fill the screen with many buttons to press). |
|||||||||||||
|