Jump to content



opengl: how to detect double click?

  • You cannot reply to this topic
8 replies to this topic

#1 nickme   Members   -  Reputation: 106

Like
0Likes
Like

Posted 04 February 2012 - 12:22 AM

hi
is there a way to detect double mouse clicks?
thanks

Ad:

#2 mhagain   Members   -  Reputation: 698

Like
0Likes
Like

Posted 04 February 2012 - 06:17 AM

No - OpenGL is for graphics only, not input.

Perhaps you mean GLUT or something similar instead?

#3 nickme   Members   -  Reputation: 106

Like
0Likes
Like

Posted 04 February 2012 - 08:56 AM

View Postmhagain, on 04 February 2012 - 06:17 AM, said:

No - OpenGL is for graphics only, not input.

Perhaps you mean GLUT or something similar instead?

yes, i meant glut

thanks

#4 SiCrane   Moderators   -  Reputation: 2378

Like
0Likes
Like

Posted 04 February 2012 - 09:12 AM

GLUT doesn't provide double click detection out of the box. You need to manually time single clicks to detect a double click. This is another thread discussing this idea.

#5 nickme   Members   -  Reputation: 106

Like
0Likes
Like

Posted 05 February 2012 - 07:13 PM

View PostSiCrane, on 04 February 2012 - 09:12 AM, said:

GLUT doesn't provide double click detection out of the box. You need to manually time single clicks to detect a double click. This is another thread discussing this idea.

hi,
thanks for the reply. i wonder can i get the coordinate (window x & y values) where the double clicks occurred? i need that info for my program to work.
thanks

#6 SiCrane   Moderators   -  Reputation: 2378

Like
0Likes
Like

Posted 05 February 2012 - 07:16 PM

The coordinates are passed as the x and y to the callback registered with glutMouseFunc().

#7 nickme   Members   -  Reputation: 106

Like
0Likes
Like

Posted 05 February 2012 - 08:52 PM

hi,

how do i differentiate a single click and a double click?

let's see my subroutine for handling mouse click:

void mouseButton(int button, int state, int x, int y) {
switch (button) {
case GLUT_LEFT_BUTTON:
if (state == GLUT_UP) {
xpos = W[C].l+(GLdouble)x*deltax-0.5*swx_size,
ypos = W[C].t-(GLdouble)y*deltay-0.5*swy_size;
move_cursor();
}
break;
default:
break;}
}

i am complete lost in implementing glutTimerFunc(). i am still looking at other's tutorials. i only want to execute move_cursor() when there is a single click and execute Zoom_in() when it is a double click. where should i place glutTimerFunc()? before move_cursor()?

thanks

#8 ssrun   Members   -  Reputation: 140

Like
0Likes
Like

Posted 05 February 2012 - 10:47 PM

Generally speaking, a "single click" event will always be fired off before the "double click" event. In Actionscript 3, a double click causes two events to be fired, what you need to do is code in such away that the action being done on the single click even naturally flows into the double click event. For example, single clicking a unit may select that particular one but double click it will select all units of that type. The flow works naturally as the first click event will select it and then the double click event will notice that the unit is selected and then search the rest of the game world for units of the same type to select.

#9 nickme   Members   -  Reputation: 106

Like
0Likes
Like

Posted 06 February 2012 - 12:25 PM

hi,

another related problem. when i pressed an arrow key, the response was almost immediate, but when i click the mouse button, there was a delay. is it my applicaton or glut's problem?

i still working on the double click. i will post when something happened.

thanks






We are working on generating results for this topic
PARTNERS