From 72ee43e9470c6fdbc6ed7ff92b85dfa5062c5762 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 6 Jan 2015 18:51:37 +0000 Subject: Added separate event handlers for mouse button clicks and mouse wheel movement. --- src/ui/widget.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'src/ui/widget.h') diff --git a/src/ui/widget.h b/src/ui/widget.h index fafdf58..a3994af 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -7,7 +7,7 @@ #ifndef __INCLUDED_UI_WIDGET_H__ #define __INCLUDED_UI_WIDGET_H__ -#include "SDL/SDL.h" +#include "SDL2/SDL.h" #include #include @@ -270,13 +270,26 @@ public: * @see on_keyrelease **/ bool event_key(const bool pressed, const int key, const unsigned int modifier); + + /** + * @brief calls the on_mousepress and on_mouserelease event handlers and sends undhandled events to the parent widget + * @see on_mousepress + * @see on_mouserelease + * */ + bool event_mouse_button(const bool pressed, const unsigned int button); + + /** + * @brief calls the on_mousewheel event handlers and sends unhandled events to the parent widget + * @see on_mousewheel + * */ + bool event_mouse_wheel(const math::Vector2f & direction); /** * @brief calls the mouse event handlers and sends unhandled keys to the parent widget * @see on_mousemove * @see on_mouseover **/ - bool event_mouse(const math::Vector2f &cursor); + void event_mouse(const math::Vector2f & cursor); /** * @brief calls the custom event handler and sends unhandled events to the parent widget @@ -284,7 +297,9 @@ public: **/ bool event_emit(Widget *sender, const Event event, void *data = 0); - /// emit a custom event + /** + * @brief emit a custom event + * */ inline void emit(const Event event, void *data=0) { event_emit(this, event, data); } @@ -355,6 +370,15 @@ protected: /// called when the mouse enters the widget virtual void on_mouseover(const math::Vector2f &cursor); + + /// called when a mouse button is pressed + virtual bool on_mousepress(const unsigned int button); + + /// called when a mouse button is released + virtual bool on_mouserelease(const unsigned int button); + + /// called when the scrollwheel is used + virtual bool on_mousewheel(const math::Vector2f & direction); /// called when the widget receives a key press virtual bool on_keypress(const int key, const unsigned int modifier); -- cgit v1.2.3