//-------------------------------------------------------------- void ofxMSAInteractiveObject::_mousePressed(ofMouseEventArgs &e) { int x = e.x; int y = e.y; int button = e.button; if(doCoordTransformation){ ofVec2f transformedCoord = screenToCanvas(ofVec2f(x,y)); x = transformedCoord.x; y = transformedCoord.y; } if(verbose) printf("ofxMSAInteractiveObject::_mousePressed(x: %i, y: %i, button: %i)\n", x, y, button); if(!enabled) { _isMousePressed[button] = false; return; } if(hitTest(x, y)) { // if mouse is over if(!isMousePressed(button)) { // if wasn't down previous frame _isMousePressed[button] = true; // update flag onPress(x, y, button); // call onPress } } else { // if mouse is not over _isMousePressed[button] = false; // update flag onPressOutside(x, y, button); } _stateChangeTimestampMillis = ofGetElapsedTimeMillis(); mousePressed(x, y, button); }
void ofxMSAInteractiveObject::_mousePressed(ofMouseEventArgs &e) { int x = e.x; int y = e.y; int button = e.button; if(verbose) printf("ofxMSAInteractiveObject::_mousePressed(x: %i, y: %i, button: %i)\n", x, y, button); if(!enabled) return; _mouseX = x; _mouseY = y; _mouseButton = button; if(hitTest(x, y)) { // if mouse is over if(!_mouseDown) { // if wasn't down previous frame onPress(x, y, button); // call onPress _mouseDown = true; // update flag } } else { // if mouse is not over onPressOutside(x, y, button); } }