//--------------------------------------------------------------
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);
}
Esempio n. 2
0
/** Hit is called whenever the button with this action is intersected
  by the input device.
  @param hitPoint,hit  Performer intersection information
  @return ACTION_CALL_ON_MISS if you want miss to be called,
          otherwise ACTION_DONE is returned
*/
int coRotButton::hit(vruiHit *hit)
{

    //VRUILOG("coRotButton::hit info: called")

    vruiRendererInterface *renderer = vruiRendererInterface::the();

    Result preReturn = renderer->hit(this, hit);
    if (preReturn != ACTION_UNDEF)
        return preReturn;

    vruiButtons *buttons = hit->isMouseHit() ? renderer->getMouseButtons() : renderer->getButtons();

    selectionState = true;
    if (buttons->wasPressed() & vruiButtons::ACTION_BUTTON)
    {
        // left Button was pressed
        onPress();
    }
    else if (buttons->wasReleased() & vruiButtons::ACTION_BUTTON)
    {
        // left Button was released
        onRelease();
    }

    updateSwitch();
    return ACTION_CALL_ON_MISS;
}
Esempio n. 3
0
    void Button::update(const sf::RenderWindow& window)
    {
        if (!isFocusable())
        {
            onLock();
            updateAppearance();
            return;
        }

        sf::Vector2i mousePos = sf::Mouse::getPosition(window);
        bool isMouseOn = mousePos.x >= (getGlobalPosition().x - getWidth() * .5f)
                        && mousePos.x <= (getGlobalPosition().x + getWidth() * .5f)
                        && mousePos.y >= (getGlobalPosition().y - getHeight() * .5f)
                        && mousePos.y <= (getGlobalPosition().y + getHeight() * .5f);
        if (isMouseOn)
        {
            if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
            {
                onPress();
            }
            else
            {
                if(mState == Button::OnPressed) { onClick(); }
                onFocus();
            }
        }
        else
        {
            lostFocus();
        }
        updateAppearance();
    }
Esempio n. 4
0
void mui::ToggleButton::clickAndNotify() {
    ofTouchEventArgs args;
    args.x = width/2;
    args.y = height/2;
    selected ^= true;
    onPress(this, args);
}
Esempio n. 5
0
/** Set button press state.
  @param state button press state
  @param generateEvent if true, onPress and onRelease events are generated
*/
void coRotButton::setState(bool state, bool generateEvent)
{
    if (generateEvent)
        onPress();
    pressState = state;
    updateSwitch();
    if (generateEvent)
        onRelease();
}
Esempio n. 6
0
void JButton::Update()
{
    if(WinS::MouseHooked){
        aimed = false;
        return;
    }

    glm::vec2 wpos = GlobalPos();
    if(inLimsV(Mouse::GetCursorPos(), wpos, wpos + size)){
        aimed = true;
        if(Mouse::IsLeftPressed()){
            if(onPress){
                onPress();
            }
        }
    } else {
        aimed = false;
    }
}
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);
	}
}
void ofxSimpleGuiToggle::keyPressed( int key ) {
	if(key==keyboardShortcut) onPress(0, 0, 0);
}
Esempio n. 9
0
//--------------------------------------------------------------
void mui::ToggleButton::touchUp( ofTouchEventArgs &touch ) {
    selected = !selected;
    pressed = false;
    onPress( this, touch );
}
Esempio n. 10
0
void ofxSimpleGuiQuadWarp::onPressOutside(int x, int y, int button) {
	onPress(x, y, button);
}
Esempio n. 11
0
//--------------------------------------------------------------
void mui::TextField::touchUp( ofTouchEventArgs &touch ){
	Root::INSTANCE->showTextField( this );
	onPress( this, touch );
}
Esempio n. 12
0
//--------------------------------------------------------------
void mui::ImageButton::touchUp( ofTouchEventArgs &touch ){
    pressed = false;
    onPress( this, touch );
}
void ofxSimpleGuiTextBox::onKeyLeft() {
	onPress(0, 0, 0);
}
void ofxSimpleGuiTextBox::onKeyEnter() {
	onPress(0, 0, 0);
}