hi
is there a way to detect double mouse clicks?
thanks
opengl: how to detect double click?
Started by nickme, Feb 04 2012 12:22 AM
8 replies to this topic
Ad:
#4 Moderators - Reputation: 2378
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 Members - Reputation: 106
Posted 05 February 2012 - 07:13 PM
SiCrane, 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
#7 Members - Reputation: 106
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
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 Members - Reputation: 140
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 Members - Reputation: 106
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
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


















