mouse button 'repeat'

Is there anyway to make a mouse button repeat? I’m basicly looking for a way to write clickable GL_QUADS that perform certian tasks. But I need them to do those tasks for as long as the button is held.

–Pope

Are you using glut or what to get the mouse?

under glutmousefunc since is only works when a button has been pressed, just make a flag to tell that the button was pressed and released.

if(button_down) mouse_flag = 1;
if(button_up) mouse_flag = 0;

Originally posted by PopeKetric:
[b]

Is there anyway to make a mouse button repeat? I’m basicly looking for a way to write clickable GL_QUADS that perform certian tasks. But I need them to do those tasks for as long as the button is held.

–Pope[/b]

Originally posted by nexusone:
[b]Are you using glut or what to get the mouse?

under glutmousefunc since is only works when a button has been pressed, just make a flag to tell that the button was pressed and released.

if(button_down) mouse_flag = 1;
if(button_up) mouse_flag = 0;

[/b]

I have that setup, and it’s working well. But I want to have it perform an acction for as long as the mouse button is down, without any motion.

–Pope

I use that setup with GLFW but nomatter what I do I cant get it to stop registering mouseclicks while the button is held down. Any ideas?

In order to get motion without any mouse action, you need to use a timer type function.
Example would be glutTimerFunc or glutIdleFunc.

here is a little code:
// Place before glutMainLoop();
glutTimerFunc( 100, TimeEvent, 1);

// Timmer routine
static void TimeEvent(int te)
{

if ( mouse_state == 1)
{
// when mouse button has been pressed down this is called until mouse up.
// do what ever stuff for mouse down here

}

glutPostRedisplay(); // Update screen with new data
glutTimerFunc( 100, TimeEvent, 1); // Reset our timmer.
}

// mouse routine

void mouse(int button, int state, int x, int y)
{

if ((button == GLUT_RIGHT_BUTTON) && (state == GLUT_DOWN))
{
// Mouse down state becomes one
mouse_state = 1;
}

if ((button == GLUT_RIGHT_BUTTON) && (state == GLUT_UP))
{
// Mouse up state becomes zero
mouse_state = 0;
}

}

Originally posted by PopeKetric:
[b] I have that setup, and it’s working well. But I want to have it perform an acction for as long as the mouse button is down, without any motion.

–Pope[/b]

Do you have any insight into my problem nexusone?

Originally posted by 31337:
I use that setup with GLFW but nomatter what I do I cant get it to stop registering mouseclicks while the button is held down. Any ideas?

So basically, what you are doing is either:

void GLFWCALL MouseButton( int button, int action )
{
    if( button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS ) button_down = 1;
    else if( button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE ) button_down = 0;
}

…or…

button_down = glfwGetMouseButton( GLFW_MOUSE_BUTTON_LEFT );

???

In any case, button_down will be flagged as long as the button is being held down.

What DO you want to accomplish?

Originally posted by nexusone:
[b]In order to get motion without any mouse action, you need to use a timer type function.
Example would be glutTimerFunc or glutIdleFunc.

here is a little code:
// Place before glutMainLoop();
glutTimerFunc( 100, TimeEvent, 1);

// Timmer routine
static void TimeEvent(int te)
{

if ( mouse_state == 1)
{
// when mouse button has been pressed down this is called until mouse up.
// do what ever stuff for mouse down here

}

glutPostRedisplay(); // Update screen with new data
glutTimerFunc( 100, TimeEvent, 1); // Reset our timmer.
}

// mouse routine

void mouse(int button, int state, int x, int y)
{

if ((button == GLUT_RIGHT_BUTTON) && (state == GLUT_DOWN))
{
// Mouse down state becomes one
mouse_state = 1;
}

if ((button == GLUT_RIGHT_BUTTON) && (state == GLUT_UP))
{
// Mouse up state becomes zero
mouse_state = 0;
}

}

[/b]

      Makes sense. Thanks a bunch.

        --Pope

Just read your message, I can only answer for GLUT on this instance, not used the other.

Originally posted by 31337:
Do you have any insight into my problem nexusone?