Scene.OnTouchListener

  • Scene.OnTouchListener is an interface used to handle touch events dispatched to a Scene in ARCore's Sceneform.

  • It provides a callback, onSceneTouch, that is triggered when a touch occurs in the scene, but only if no node in the scene has already handled the touch event.

  • The onSceneTouch callback receives a HitTestResult indicating what was touched (or null if nothing) and a MotionEvent containing details of the touch action.

  • Returning true from onSceneTouch indicates that the listener has consumed the event, preventing further processing.

public static interface Scene.OnTouchListener

Interface definition for a callback to be invoked when a touch event is dispatched to a scene. The callback will be invoked after the touch event is dispatched to the nodes in the scene if no node consumed the event.

Public Methods

abstract boolean
onSceneTouch(HitTestResult hitTestResult, MotionEvent motionEvent)
Called when a touch event is dispatched to a scene.

Public Methods

public abstract boolean onSceneTouch (HitTestResult hitTestResult, MotionEvent motionEvent)

Called when a touch event is dispatched to a scene. The callback will be invoked after the touch event is dispatched to the nodes in the scene if no node consumed the event. This is called even if the touch is not over a node, in which case getNode() will be null.

Parameters
hitTestResult represents the node that was touched
motionEvent the motion event
Returns
  • true if the listener has consumed the event