11.2. SoTouchEvent

SoTouchEvent SoTouchEvent SoTouchEvent is the base class for touch events in the Open Inventor model. A touch event typically represents a user finger action on a touch monitor. A series of SoTouchEvent SoTouchEvent SoTouchEvent always begins with a start event, which is released when you put down your finger and ends when you lift it up with one end event.

SoTouchEvent SoTouchEvent SoTouchEvent contains a lot of information :

  • The state indicates if the finger is on the screen (which means that the finger was not touching the device at the previous event), is moving (the finger was put down or moving during the previous event) or is up (this finger was touching the screen during the previous event). The getState() function gives you this state: UP, DOWN or MOVE.

  • Each event corresponds to one finger. This finger is identified by an integer. You can query this identifier with getFingerId().

  • getPosition() which is an SoEvent SoEvent SoEvent function, getPreviousPosition() and getFirstPosition() return respectively the current position, the previous position and the first position of the fingers.

  • getDisplacement() gets the displacement vector which is the displacement between the previous position and the current one.

  • getSpeed() and getPreviousSpeed() returns respectively the current speed and the previous speed of the corresponding finger calculated with the time elapsed since previous event given by getElapsedTimeSincePreviousEvent(). These two speeds are necessary to calculate the acceleration given by getAcceleration().

  • getTouchManager() returns the corresponding touch manager which released the event. It allows you to have information about other fingers.

Figure below illustrates all information available in a SoTouchEvent SoTouchEvent SoTouchEvent for one finger at a given time.

All information available at date t in touch event

Figure 11.1.  All information available at date t in touch event