diff --git a/src/ofxBaseJoint.cpp b/src/ofxBaseJoint.cpp index cf528f2..11195ab 100644 --- a/src/ofxBaseJoint.cpp +++ b/src/ofxBaseJoint.cpp @@ -2,10 +2,24 @@ ofxBaseJoint::ofxBaseJoint() { - + registerMouseEvents(); } ofxBaseJoint::~ofxBaseJoint() { - + unregisterMouseEvents(); +} + +void ofxBaseJoint::registerMouseEvents() +{ + ofAddListener(ofEvents().mousePressed, this, &ofxBaseJoint::mousePressed); + ofAddListener(ofEvents().mouseReleased, this, &ofxBaseJoint::mouseReleased); + ofAddListener(ofEvents().mouseDragged, this, &ofxBaseJoint::mouseDragged); +} + +void ofxBaseJoint::unregisterMouseEvents() +{ + ofRemoveListener(ofEvents().mousePressed, this, &ofxBaseJoint::mousePressed); + ofRemoveListener(ofEvents().mouseReleased, this, &ofxBaseJoint::mouseReleased); + ofRemoveListener(ofEvents().mouseDragged, this, &ofxBaseJoint::mouseDragged); } \ No newline at end of file diff --git a/src/ofxBaseJoint.h b/src/ofxBaseJoint.h index 1e787f4..34549c6 100644 --- a/src/ofxBaseJoint.h +++ b/src/ofxBaseJoint.h @@ -8,6 +8,9 @@ public: ofxBaseJoint(); ~ofxBaseJoint(); + void registerMouseEvents(); + void unregisterMouseEvents(); + virtual void mousePressed(ofMouseEventArgs& args){}; virtual void mouseReleased(ofMouseEventArgs& args){}; virtual void mouseDragged(ofMouseEventArgs& args){}; diff --git a/src/ofxCircleJoint.cpp b/src/ofxCircleJoint.cpp new file mode 100644 index 0000000..1e2a91c --- /dev/null +++ b/src/ofxCircleJoint.cpp @@ -0,0 +1,16 @@ +#include "ofxCircleJoint.h" + +void ofxCircleJoint::mousePressed(ofMouseEventArgs &args) +{ + cout << "mouse pressed" << endl; +} + +void ofxCircleJoint::mouseReleased(ofMouseEventArgs &args) +{ + cout << "mouse released" << endl; +} + +void ofxCircleJoint::mouseDragged(ofMouseEventArgs &args) +{ + cout << "mouse dragged" << endl; +} \ No newline at end of file diff --git a/src/ofxCircleJoint.h b/src/ofxCircleJoint.h new file mode 100644 index 0000000..60aca84 --- /dev/null +++ b/src/ofxCircleJoint.h @@ -0,0 +1,15 @@ +#ifndef H_OFX_CIRCLE_JOINT +#define H_OFX_CIRCLE_JOINT + +#include "ofMain.h" +#include "ofxBaseJoint.h" + +class ofxCircleJoint : public ofxBaseJoint +{ +public: + void mousePressed(ofMouseEventArgs& args); + void mouseReleased(ofMouseEventArgs& args); + void mouseDragged(ofMouseEventArgs& args); +}; + +#endif \ No newline at end of file