//-------------------------------------------------------------- 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::_mouseReleased(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::_mouseReleased(x: %i, y: %i, button: %i)\n", x, y, button); if(!enabled) { _isMousePressed[button] = false; return; } if(hitTest(x, y)) { onRelease(x, y, button); } else { if(isMousePressed(button)) onReleaseOutside(x, y, button); } _isMousePressed[button] = false; _stateChangeTimestampMillis = ofGetElapsedTimeMillis(); mouseReleased(x, y, button); }
//-------------------------------------------------------------- void ofxMSAInteractiveObject::_mouseDragged(ofMouseEventArgs &e) { int x = e.x; int y = e.y; int button = e.button; if(verbose) printf("ofxMSAInteractiveObject::_mouseDragged(x: %i, y: %i, button: %i)\n", x, y, button); if(!enabled) { _isMousePressed[button] = false; return; } if(hitTest(x, y)) { // if mouse is over the object if(!_isMouseOver) { // if wasn't over previous frame // onPress(x, y); // call onPress - maybe not _isMouseOver = true; // update flag onRollOver(x, y); // call onRollOver } onDragOver(x, y, button); // and trigger onDragOver } else { if(_isMouseOver) { // if mouse is not over the object, but the flag is true (From previous frame) onRollOut(); // call onRollOut _isMouseOver = false; // update flag } if(isMousePressed(button)) { onDragOutside(x, y, button); } _isMousePressed[button] = false; } _stateChangeTimestampMillis = ofGetElapsedTimeMillis(); mouseDragged(x, y, button); }
void MyGLWidget::mousePressEvent(QMouseEvent * e) { mouse[e->button()] = true; mouseMoved = false; previousMouseX = e->x(); previousMouseY = e->y(); if (isMousePressed(Qt::LeftButton)) { addPoint(e); } }
void WeavingPoint::draw() { if(bVisible){ if(isMousePressed()) ofSetHexColor(DOWN_COLOR); else if(isMouseOver()) ofSetHexColor(OVER_COLOR); else ofSetHexColor(IDLE_COLOR); ofRect(x, y, width, height); } /* if(isMousePressed()) { ofNoFill(); ofSetColor(0xFF0000); ofRect(x, y, width, height); } else if(isMouseOver()){ ofNoFill(); ofSetColor(0x00FF00); ofRect(x, y, width, height); }*/ }
MouseButton EventDescriptor::mousePressedButton() const { assert(isMousePressed()); return mDescriptor.mousePressed.button; }
void Window::mouseMoved(glm::vec2 delta, glm::vec2 position) { if (isMousePressed(MouseButtons::Left) && getPointedElement() == nullptr) setPosition(getPosition() + delta); else GuiContainerElement::mouseMoved(delta, position); }