Adding mouse events to our interactive object
In this recipe, we will continue with the previous recipe, Creating an interactive object that responds to the mouse and add the mouse events to our InteractiveObject
class so that other objects can register and receive notifications whenever a mouse event occurs.
Getting ready
Grab the code from the recipe Creating an interactive object that responds to the mouse and add it to your project, as we will continue on from what was made earlier.
How to do it…
We will make our InteractiveObject
class and send its own events whenever it interacts with the cursor.
Let's create a class to use as an argument when sending events. Add the following code in the file
InteractiveObject.h
right before theInteractiveObject
class declaration:class InteractiveObject; class InteractiveObjectEvent: public ci::app::Event{ public: enum EventType{ Pressed, PressedOutside, Released, ReleasedOutside, RolledOut, RolledOver, Dragged }; InteractiveObjectEvent( InteractiveObject...