Jump to content
  • Advertisement


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

Jesper T

Catching mouseclicks

This topic is 6197 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

For keys i use e.g.: if(keys[''P'']) { thenDoThis(); } But how do I check if a mousebuttomhas been pressed ? ( could it be mouse[LEFT] or something ?? ) Thanks 4 ny help (This is proabably very simple, but if it isn''t, maybe someone can point me a tutorias or something ? )

Share this post

Link to post
Share on other sites
If you''re programming C++ in Windows, and you don''t need a fast repeat rate for holding down the mouse button, the easiest way to do it is to use Windows Messages, and process it in your default message handler, (see SDK docs for info if you''re unfamiliar with Windows Messages).

There are a number of states that can be processed easily, such as:

To detect if the left mouse button was clicked, you would put something like the code below in your message handler:

//code or function call to be called when
//button is pushed

} break;

If you need a fast repeat rate, however, and more instantaneous response, such as using the repeat in a game to fire a stream of fire, bullets, etc., you may wish to look into DirectX''s DirectInput, or the GetAsyncKeyState function (if not interested in DirectX.)

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!