Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Deline

Mouse Over

This topic is 5224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Is there a function for detecting a mouse over an area (not clicked). The idea is that when the mouse over an option on the menu the writing gets bigger or changes colour etc. and when they click something happens(this already works). Thanks

Share this post


Link to post
Share on other sites
Advertisement
in your wndproc add:

case WM_MOUSEMOVE:
{
POINT pt;
GetCursorPos(&pt);
ScreenToClient(&pt);
mousex = pt.x;
mousey = pt.y;
}
break;

then somewhere add

bool MouseInRect(RECT rect)
{
if((mousex>=rect.left)&&(mousex<=rect.right))
{
if((mousey>=rect.top)&&(mousey<=rect.bottom))
{
return true;
}
}
return false;
}

Share this post


Link to post
Share on other sites
When using GLUT you specify, in the main or an init procedure, the functions you want to use to handle the keyboard and mouse interactions, the rendering, etc...
For example:
glutMotionFunc(MouseMove);

Put the code you want to execute in the function you declared as handling the mouse motion. To use the example used by mike, write something like:


void MouseMove(int x, int y)
{
if((x>=rect.left)&&(x<=rect.right))
{
if((y>=rect.top)&&(y<=rect.bottom))
{
functiontocall();
}
}
alternatefunctiontocall();
}


Where rect has been defined to contain the zone to detect.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!