Permalink
Browse files

added getMousePressed and getMouseX, getMouseY functions to fenster

  • Loading branch information...
1 parent 5e8b996 commit d777a33bfb30e341f6beb70a82c398764abcc4cf Philip Whitfield committed Apr 1, 2012
Showing with 30 additions and 0 deletions.
  1. +23 −0 src/ofxFenster.cpp
  2. +7 −0 src/ofxFenster.h
View
@@ -220,6 +220,9 @@ void ofxFenster::mousePressed(int x, int y, int button) {
mouseEventArgs.x = x;
mouseEventArgs.y = y;
mouseEventArgs.button = button;
+
+ pressedMouseButtons.insert(button);
+
ofNotifyEvent(ofEvents.mousePressed, mouseEventArgs);
//ofNotifyMousePressed(x,y,button);
ofNotifyEvent(events.mousePressed, mouseEventArgs);
@@ -229,6 +232,7 @@ void ofxFenster::mousePressed(int x, int y, int button) {
(*it)->mousePressed(x, y, button, this);
++it;
}
+
}
void ofxFenster::mouseReleased() {
@@ -240,6 +244,9 @@ void ofxFenster::mouseReleased(int x, int y, int button) {
mouseEventArgs.x = x;
mouseEventArgs.y = y;
mouseEventArgs.button = button;
+
+ pressedMouseButtons.erase(button);
+
ofNotifyEvent(ofEvents.mouseReleased, mouseEventArgs);
//ofNotifyMouseReleased(x,y,button);
ofNotifyEvent(events.mouseReleased, mouseEventArgs);
@@ -506,3 +513,19 @@ void ofxFenster::setDragAndDrop(bool on) {
win->setAcceptDragOperation(on);
}
+bool ofxFenster::getMousePressed(int button)
+{
+ if(button==-1) return pressedMouseButtons.size();
+ return pressedMouseButtons.find(button)!=pressedMouseButtons.end();
+}
+
+int ofxFenster::getMouseX()
+{
+ return mousePos.x;
+}
+
+int ofxFenster::getMouseY()
+{
+ return mousePos.y;
+}
+
View
@@ -9,6 +9,7 @@
#include "ofAppBaseWindow.h"
#include "ofBaseApp.h"
#include "ofGLRenderer.h"
+#include <set>
class GHOST_IWindow;
@@ -132,6 +133,10 @@ class ofxFenster
void mouseReleased(int btn);
void fileDropped(ofDragInfo info);
+ bool getMousePressed(int button = -1);
+ int getMouseX();
+ int getMouseY();
+
void disableSetupScreen();
void enableSetupScreen();
int getFrameNum();
@@ -203,6 +208,8 @@ class ofxFenster
ofPtr<ofBaseRenderer> renderer;
ofPoint mousePos;
ofPoint mouseLastPos;
+ static set<int> pressedMouseButtons;
+
int width;
int height;
ofPoint pos;

0 comments on commit d777a33

Please sign in to comment.