This project creates a button enclosed in a home screen that responds to mouse_over event, it contains an event management system, different images for mouse_over and mouse_out and can be extended to all types of events like on_release on_click.. but also the event mechanism can be extended to catch key events
You'll be expecting that creating a button with mouse events in pygame should be a drag and prop like feature, it seems that it's not. Actually you need some OOP and design patterns knowledge to implement it. I used Observer pattern, inheritance, composition, and other OOP techiques.
The overview for the POC is:
* a main screen class that will hold the background image, a button and every other widgets in it(other eventual buttons for eg.)
* a event broadcating class that will contain all sorts of events like onClick, onKeyPress, it will register/unregister events and trigger actions..
* a main program loop that will listen to actions like: press a key or a mouse button.
The class Diagram looks like this:
This is how the routing of the messages works: