- Sceneform SDK for Android
was open sourced and archived ( github.com/google-ar/sceneform-android-sdk
) with version 1.16.0.
- This site ( developers.google.com/sceneform
) serves as the documentation archive for the previous version, Sceneform SDK for Android
1.15.0.
- Do not use version 1.17.0 of the Sceneform Maven artifacts
.
- The 1.17.1 Maven artifacts can be used. Other than the version, however, the 1.17.1 artifacts are identical to the 1.15.0 artifacts.
Node.OnTouchListener
Stay organized with collections
Save and categorize content based on your preferences.
Public Methods
public
abstract
boolean
onTouch
( HitTestResult
hitTestResult, MotionEvent
motionEvent)
Handles when a touch event has been dispatched to a node.
On ACTION_DOWN
events, getNode()
will always be
this node or one of its children. On other events, the touch may have moved causing the getNode()
to change (or possibly be null).
Parameters
Returns
- true if the listener has consumed the event, false otherwise
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eNode.OnTouchListener\u003c/code\u003e is an interface used to handle touch events dispatched to a Sceneform node.\u003c/p\u003e\n"],["\u003cp\u003eIt provides a callback method \u003ccode\u003eonTouch\u003c/code\u003e which is invoked before the node's \u003ccode\u003eonTouchEvent\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eonTouch\u003c/code\u003e receives a \u003ccode\u003eHitTestResult\u003c/code\u003e indicating the touched node and a \u003ccode\u003eMotionEvent\u003c/code\u003e with event details.\u003c/p\u003e\n"],["\u003cp\u003eReturning \u003ccode\u003etrue\u003c/code\u003e from \u003ccode\u003eonTouch\u003c/code\u003e consumes the event, preventing further processing by other listeners or the node itself.\u003c/p\u003e\n"]]],["The `Node.OnTouchListener` interface defines a callback for touch events dispatched to a node. It has one method, `onTouch`, which handles these events. `onTouch` receives a `HitTestResult`, indicating the touched node and location, and a `MotionEvent` with event details. On `ACTION_DOWN`, the touched node will always be the current node or a child. The `onTouch` method returns `true` if the event is consumed, or `false` if not.\n"],null,["# Node.OnTouchListener\n\npublic static interface **Node.OnTouchListener** \nInterface definition for a callback to be invoked when a touch event is dispatched to this\nnode. The callback will be invoked before [onTouchEvent(HitTestResult, MotionEvent)](/sceneform/reference/com/google/ar/sceneform/Node#onTouchEvent(com.google.ar.sceneform.HitTestResult,%20android.view.MotionEvent)) is\ncalled. \n\n### Public Methods\n\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract boolean | [onTouch](/sceneform/reference/com/google/ar/sceneform/Node.OnTouchListener#onTouch(com.google.ar.sceneform.HitTestResult,%20android.view.MotionEvent))([HitTestResult](/sceneform/reference/com/google/ar/sceneform/HitTestResult) hitTestResult, [MotionEvent](https://developer.android.com/reference/android/view/MotionEvent) motionEvent) Handles when a touch event has been dispatched to a node. |\n\nPublic Methods\n--------------\n\n#### public abstract boolean\n**onTouch**\n([HitTestResult](/sceneform/reference/com/google/ar/sceneform/HitTestResult) hitTestResult, [MotionEvent](https://developer.android.com/reference/android/view/MotionEvent) motionEvent)\n\nHandles when a touch event has been dispatched to a node.\n\nOn [ACTION_DOWN](https://developer.android.com/reference/android/view/MotionEvent#ACTION_DOWN) events, [getNode()](/sceneform/reference/com/google/ar/sceneform/HitTestResult#getNode()) will always be\nthis node or one of its children. On other events, the touch may have moved causing the\n[getNode()](/sceneform/reference/com/google/ar/sceneform/HitTestResult#getNode()) to change (or possibly be null). \n\n##### Parameters\n\n| hitTestResult | represents the node that was touched and information about where it was touched |\n| motionEvent | the MotionEvent object containing full information about the event |\n|---------------|---------------------------------------------------------------------------------|\n\n##### Returns\n\n- true if the listener has consumed the event, false otherwise"]]