PDA

View Full Version : Double click



Felipe Ruiz
05-06-2010, 03:52 PM
Hey all, again.

I was wondering, how can I treat double-clicks using glut? I was trying to do a zoom function for my Julia set with the double-click, but I can't get anything to work..

StuckInBorland
05-09-2010, 05:26 AM
Hi

I don't know if there is a special handle for double click,but
I can offer you a workaround until you find a better solution (if there is one)
Use regular one click event and count clicks - every second click reset the counter and code must be smth like this:


void processMouse(int mouseButton, int mouseState, int x, int y)
{
if (mouseState == GLUT_DOWN)
{
if (mouseButton == GLUT_LEFT_BUTTON)// GLUT_MIDDLE_BUTTON or GLUT_RIGHT_BUTTON
{
CountClicks++;
if(CountClicks == 2)
{
// your code.....
CountClicks = 0;
}
}

}

And you must add in your main init this
glutMouseFunc(processMouse);

Hope this helps.