void handleMouseClick(const osgGA::GUIEventAdapter& ea) { // Get the current button mask int buttonMask = ea.getButtonMask(); // Check if the left mouse button is currently held down if (buttonMask & osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON) { // Perform left-click action... } }
bool isRightMouseDown(const osgGA::GUIEventAdapter& ea) { // Get the current button mask int buttonMask = ea.getButtonMask(); // Check if the right mouse button is currently held down return (buttonMask & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON) != 0; }In this example, the function "isRightMouseDown" returns a boolean value indicating whether or not the right mouse button is currently held down. The function uses the GUIEventAdapter::getButtonMask function to get the current button mask, and then uses the bitwise "and" operator (&) to compare the value of buttonMask with the predefined constant value for the right mouse button. The expression "!= 0" is used to convert the result of the bitwise "and" operation to a boolean value. Package library: OpenSceneGraph (OSG)