Class TouchEventSystem


  • public class TouchEventSystem
    extends java.lang.Object
    Manages propagation of touch events to node's within a scene.

    The way that touch events are propagated mirrors the way touches are propagated to Android Views.

    When an ACTION_DOWN event occurs, that represents that start of a gesture. ACTION_UP or ACTION_CANCEL represents when a gesture ends. When a gesture starts, the following is done:

    • Constructor Detail

      • TouchEventSystem

        public TouchEventSystem()
    • Method Detail

      • setOnTouchListener

        public void setOnTouchListener​(@Nullable
                                       Scene.OnTouchListener onTouchListener)
        Register a callback to be invoked when the scene is touched. The callback is invoked before any node receives the event. If the callback handles the event, then the gesture is never received by the nodes.
        Parameters:
        onTouchListener - the touch listener to attach
      • addOnPeekTouchListener

        public void addOnPeekTouchListener​(Scene.OnPeekTouchListener onPeekTouchListener)
        Adds a listener that will be called before the Scene.OnTouchListener is invoked. This is invoked even if the gesture was consumed, making it possible to observe all motion events dispatched to the scene. This is called even if the touch is not over a node, in which case HitTestResult.getNode() will be null. The listeners will be called in the order in which they were added.
        Parameters:
        onPeekTouchListener - the peek touch listener to add
      • removeOnPeekTouchListener

        public void removeOnPeekTouchListener​(Scene.OnPeekTouchListener onPeekTouchListener)
        Removes a listener that will be called before the Scene.OnTouchListener is invoked. This is invoked even if the gesture was consumed, making it possible to observe all motion events dispatched to the scene. This is called even if the touch is not over a node, in which case HitTestResult.getNode() will be null.
        Parameters:
        onPeekTouchListener - the peek touch listener to remove
      • onTouchEvent

        public void onTouchEvent​(HitTestResult hitTestResult,
                                 android.view.MotionEvent motionEvent)