PDA

View Full Version : right click menu then add text



Sniipe
11-30-2005, 05:34 AM
Hello, I'm fairly new to opengl but am learning fast. I have a display at the moment with a menu with right click. One of the menu items is add text.
When I click on add text I would like to be able to enter text from the keyboard onto the screen.

The coordinate to start the text should be at the point of right clicking for the menu. Is this the right steps to persue?
-So to do this I need to save that value and pass it to the function by using "glutMouseFunc(drawText);" A printf tells me that I have the right coordinates but that only occurs when I left click. So far I can display a pre-defined character at the left mouse click.

What should I do next? Any pointers? Cheers.

songho
11-30-2005, 06:34 AM
Sniipe,
Try something like this;

// register mouse callback
glutMouseFunc(mouseCB);
...

// mouse callback function
void mouseCB(int button, int state, int x, int y)
{
if(button == GLUT_RIGHT_BUTTON)
{
if(state == GLUT_DOWN)
drawText(x, y); // this is your draw text function
else if(state == GLUT_UP)
; //
}
}