Jump to content
  • Advertisement

Archived

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

hogosha

SDL Buttons for GUI

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

Im in the middle of making a game that''s using SDL and MySQL. Now I have come to the part where I need to make buttons and take in mouse input. Now my question is, how would i go about handling mouse input and letting the buttons see the the mouse was clicked and released in that area without any problems. I think their could be problems just can''t really figure out where exactly. But i''d appreciate some input on it.

Share this post


Link to post
Share on other sites
Advertisement
My system sort of works like a tree. The tree is made of up controls, and everything else is made from inheriting from that control class. The desktop is the base of the tree. Whenever the user clicks the mouse, a signal is sent to the desktop via a function (something like Click(x, y)). Click() is a function defined in the control class that tests each of it''s children for a click (a simple point-in-rectangle check), and then it calls the children''s Click() function if there''s a match. Then, once all that is done, the Click() function for each controls calls an onClick() function, which is defined for each type of control (a button would have a specific onClick() defined, a checkbox would have another one defined, etc.

Maybe that helps.

Game Development Wiki

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!