Exemple #1
0
bool HouseRenderer::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelData, bool dragging, bool clicked) {
    if (dragging) {
        if (leftButtonDown()) {
            // Dragging left button
        }
        if (rightButtonDown()) {
            // Dragging right button
        }
        if (middleButtonDown()) {
            // Dragging middle button
        }
        // Dragging should be handled by the touchEvent
        return false;
    } else if (clicked) {
        // handle in the touchEvent
        return false;
    } else if (evt == Mouse::MOUSE_MOVE) {
        checkHover(x, y);
    } else if (evt == Mouse::MOUSE_WHEEL) {
        // Scrolled the mouse wheel
        if (wheelData > 5) {
            wheelData = 5;
        } else if (wheelData < -5) {
            wheelData = -5;
        }
        zoomLevel *= (1 - (float)wheelData * ZOOM_SPEED);
        setCamera();
        // reset hover when zooming, as the mouse moves relative to the screen
        checkHover(x, y);
    } else {
        // Clicked any button on the mouse
        if (evt == Mouse::MouseEvent::MOUSE_RELEASE_LEFT_BUTTON) {
            //houseRendererForm->setState(Control::State::NORMAL);
        }
        
        if (evt == Mouse::MOUSE_PRESS_LEFT_BUTTON && prevHover != NULL) {
            prevHover->setHover(false);
            prevHover = NULL;
        } else if (evt == Mouse::MOUSE_RELEASE_LEFT_BUTTON) {
            int id = getViewTileId(x, y);
            if (id != -1) {
                prevHover = house->getFloorTile(id)->setHover(true);
            }
        }
        // Mouse click should be handled by touchEvent
        return false;
    }
    return true;
}
void KeyMap::update(Vector2i m_pos,bool clik,string keyIn)
{

    checkHover(m_pos);
    checkClick(clik);
    activeCharDisplay.setString(activeChar);
    if(toggled && keyIn.size() != 0)
    {
        activeChar = keyIn[0];
        toggle();
    }

    return;
}
Exemple #3
0
	bool WireframeActor::mouseOver()
	{
	    if(mouseover)
		{
			if(Application::checkTouchActive(currentTouchId))
			{
				if(checkHover((float)Application::TouchX(currentTouchId), (float)Application::TouchY(currentTouchId)))
				{
					return true;
				}
			}
		}
		ArrayList<TouchPoint> points = Application::getTouchPoints();
		for(int i=0; i<points.size(); i++)
		{
			TouchPoint&point = points.get(i);
			if(checkHover(point.x, point.y))
			{
				touchId = point.ID;
				return true;
			}
		}
		return false;
	}