
Reece Dunn wrote:
John Torjo wrote:
Hi Reece,
[3] The support for events via "listeners". This will most likely be geared towards key/mouse events and "action" events (e.g. when the user presses on a button).
I'm not a big fan of listeners. You need to do a lot of coding manually to set them, etc. I've implemented them totally different - using event handler classes.
My idea was something along the lines of:
class MouseEvent { public: static const int LeftButton = 0; static const int MiddleButton = 1; static const int RightButton = 2; private: int button; unsigned int vkeys; win::api::point pt; public: inline MouseEvent( int, WPARAM, LPARAM ); };
MouseEvent::MouseEvent( int btn, WPARAM wp, LPARAM lp ): button( btn ), vkey( wp ), pt( lp ) { }
class MouseListener { public: virtual void mouseMove( const MouseEvent & ); virtual void mouseButtonDown( const MouseEvent & ); virtual void mouseButtonUp( const MouseEvent & ); virtual void mouseButtonDoubleClick( const MouseEvent & ); public: virtual ~MouseButtonListener(); };
With a common listener interface for GUI object actions, e.g. pressing a mouse button, selecting an item in a listbox, editing text, etc.
Why not use boost::signals for your event interface. It is much better than hand-coded actions and listeners, since any type of function can handle an event. The technology is already in Boost so why re-invent the wheel.