示例#1
0
void ChessBoard::mousePressEvent(QMouseEvent *evt)
{
    if ( evt->button() == Qt::LeftButton )
        leftButtonDown( evt );
    else if ( evt->button() == Qt::RightButton )
        rightButtonDown( evt );
    QWidget::mousePressEvent( evt );
}
示例#2
0
int dTrayIcon::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: leftButtonDown(); break;
        case 1: rightButtonDown(); break;
        }
        _id -= 2;
    }
    return _id;
}
示例#3
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;
}
示例#4
0
void mouseControl::keyPressed(int key){

    switch (key){
        case	OF_KEY_LEFT:
            myMouse.x -= 10;
            if(getLeftButton()){ //if getLeftButton == true, we're dragging
                leftMouseDragged(myMouse);
            } else move(myMouse);
			break;

        case	OF_KEY_RIGHT:
            myMouse.x += 10;
            if(getLeftButton()){ //if getLeftButton == true, we're dragging
                leftMouseDragged(myMouse);
            }else move(myMouse);
			break;

        case	OF_KEY_UP:
            myMouse.y -= 10;
            if(getLeftButton()){ //if getLeftButton == true, we're dragging
                leftMouseDragged(myMouse);
            }else move(myMouse);
			break;

        case	OF_KEY_DOWN:
            myMouse.y += 10;
            if(getLeftButton()){ //if getLeftButton == true, we're dragging
                leftMouseDragged(myMouse);
            }else move(myMouse);
			break;
        case    '1':
            leftButtonDown(myMouse);
            break;

        case    '2':
            rightButtonDown(myMouse);
            break;
    }
}