incorrect generation of click events

Create issue
Issue #153 resolved
Former user created an issue

Automatic migration. Original reporter: "ilveroluca"

Using PushButton, the button generates single, double, and triple click events, even though the mouse clicks are seconds apart.

click 1 - EventClicked click 2 - EventMouseDoubleClick click 3 - EventMouseTripleClick click 4 - EventClicked click 5 - EventMouseDoubleClick click 6 - EventMouseTripleClick click 7 - EventClicked ...

I've tracked the problem down to an erroneous use of clock() in class SimpleTimer in CEGUISystem.cpp. clock() returns "the number of clock ticks of elapsed processor time"*, not elapsed wall clock time. My program sleeps while waiting for events (SDL_WaitEvent) and so does not use the processor between clicks, so clock returns the same number for different clicks and CEGUI thinks they were done very close in time. A proper implementation of SimpleTimer on Linux might use gettimeofday. On Windows clock() seems to work, but since reading the documentation tells us that clock() is not what we want it would be better to replace it with something like timeGetTime()

Reproducibility: always

OS: Linux, OS build: , Platform:

Comments (3)

  1. Former user Account Deleted

    Original reporter: Eldarin

    I have tried to replace clock () function with gettimeofday () on linux and GetSystemTime () on windows. I tested it on linux and it works well. I hope it works on windows too. I don't know what to do with MacOS version. Maybe somebody can use this patch as a starting point in solving the issue.

  2. Former user Account Deleted

    Original reporter: ilveroluca

    I propose a simpler patch, isolating the platform-specific portions into a single function. I don't know what might work with MacOS

  3. Paul Turner

    This is fixed in the trunk, rev. 1530.

    I went with ilveroluca's patch in the end.

    Not 100% sure about MacOS either, though believe that the linux solution would likely apply there too. Since I don't have a Mac, and CEGUI is without an active Mac maintainer I did nothing for now.

  4. Log in to comment