• Advertisement
Sign in to follow this  

Gui's and signal/slot or observers

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

A lot of GUI systems work with observers or signal slot systems. Is there any particular reason why this is done? Is it somehow unacceptable to use a system where once every frame, you call "draw" and "handle" to all gui objects (you call it only once because a container contains them all and that one passes the handle and call draws on to all the elements), and where inside the gameloop you do something like "if(exitButton.pressed()) exit();"? I'm just asking because all the GUI systems I know don't do it that way, to know if my way may is maybe unacceptable.

Share this post


Link to post
Share on other sites
Advertisement
It is not unacceptable to use another system. Irrlicht for instance uses a similar system to yours (with regards to "draw" and "handle"), but for knowing whether a button was clicked you make a class that inherits from IEventReceiver and you implement your own OnEvent-method in which you can react to GUI messages like button clicks.

I think that that way is a rather straight forward way to doing gui's and produces good results. I guess the observer pattern could be usefull if you wanted to implement skins.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement