Handling mouse and keyboard inputs

The osgGA::GUIEventAdapter class manages all kinds of OSG supported events, including both setting and getting methods for them. The getEventType() method returns the current GUI event stored in an event adapter. Every time the overriding handle() method is called, we have to check this first to determine the event type and take appropriate countermeasures.

The following table shows the main event types in OSG, as well as the related methods used to get the necessary event arguments:

Event type value

Description

Related methods

PUSH/RELEASE/ DOUBLECLICK

The push, release, and double-click events of the mouse

Get the current mouse position: getX(), getY()

Get the related button: getButton(); return value can ...

Get OpenSceneGraph 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.