void mouse(int button, int state, int x, int y) { if ( state == 0 ) { switch ( button ) { case GLUT_LEFT_BUTTON: break; case GLUT_MIDDLE_BUTTON:tball.setAutoPosition(true); break; case GLUT_RIGHT_BUTTON: tball.setAutoPositionNeg(true); break; } mouseb |= 1 << button; } else if ( state == 1 ) { switch ( button ) { case GLUT_LEFT_BUTTON: break; case GLUT_MIDDLE_BUTTON:tball.setAutoPosition(false); break; case GLUT_RIGHT_BUTTON: tball.setAutoPositionNeg(false); break; } mouseb &= ~(1 << button); } lastx = x; lasty = y; }
void MyOSGQGLWidget::mouseReleaseEvent ( QMouseEvent *me ) { switch ( me->button() ) { case MidButton: tball.setAutoPosition(false); break; case RightButton: tball.setAutoPositionNeg(false); break; default: break; } _mouseb &= me->button(); _lastx = me->x(); _lasty = me->y(); }