Sceneform-android-sdk: I want to listen for double-click events on the node

Created on 6 Jun 2018  路  2Comments  路  Source: google-ar/sceneform-android-sdk

when I tried to use the method 'setOnTapListener'which belonged to the Node , I used the class named 'GestureDetector' in the callback of this method ,then I received nothing from the class of its method named 'onDoubleTap'.
So I want to know what to do next to listen for double-click events on the node.

`val curGestureDetector = GestureDetector(this@MainActivity, object : GestureDetector.SimpleOnGestureListener() {
override fun onDoubleTap(e: MotionEvent?): Boolean {
//It's not executed here
Log.i(TAG, "鐗╀綋鍙屽嚮")
transformableNode.parent.removeChild(transformableNode)
return true
}
})

        transformableNode.setOnTapListener { hitTestResult, motionEvent_ ->
            //Here it executed
            Log.i(TAG, "鐗╀綋tap")
            curGestureDetector.onTouchEvent(motionEvent_)
        }`
question

Most helpful comment

The Tap listener is only for receiving events when a tap gesture has occurred (down and then up within a slop threshold) and is similar to View.OnClickListener in Android. To use the GestureDetector, you need to pass all touch events into the gesture detector, not just the tap. You can do this by making a subclass of Node or TransformableNode and overriding Node.onTouchEvent

All 2 comments

The Tap listener is only for receiving events when a tap gesture has occurred (down and then up within a slop threshold) and is similar to View.OnClickListener in Android. To use the GestureDetector, you need to pass all touch events into the gesture detector, not just the tap. You can do this by making a subclass of Node or TransformableNode and overriding Node.onTouchEvent

@dsternfeld7 Thanks very much, you have helped me a lot .the problem has been solved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PaulTVungle picture PaulTVungle  路  3Comments

JessHolle picture JessHolle  路  3Comments

StevenOttoG picture StevenOttoG  路  4Comments

peronecode picture peronecode  路  3Comments

scolar picture scolar  路  4Comments