Created
February 12, 2022 08:40
-
-
Save sarimmehdi/5c111e34b09649af406891c3cb35d031 to your computer and use it in GitHub Desktop.
Updated code for touch event listener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arSceneView.scene.setOnTouchListener { | |
hitTestResult : HitTestResult?, motionEvent : MotionEvent? -> | |
gestureDetectorCompat!!.onTouchEvent(motionEvent) | |
when (gestureDetector.gestureType) { | |
GestureDetector.GestureType.SINGLE_TAP -> { | |
if (hitTestResult!!.node == null) { | |
Toast.makeText(this, "SINGLE TAP performed", Toast.LENGTH_SHORT).show() | |
} | |
else { | |
Toast.makeText(this, "SINGLE TAP performed on a node", Toast.LENGTH_SHORT).show() | |
} | |
} | |
GestureDetector.GestureType.DOUBLE_TAP -> { | |
if (hitTestResult!!.node == null) { | |
Toast.makeText(this, "DOUBLE TAP performed", Toast.LENGTH_SHORT).show() | |
} | |
else { | |
Toast.makeText(this, "DOUBLE TAP performed on a node", Toast.LENGTH_SHORT).show() | |
} | |
} | |
GestureDetector.GestureType.LONG_PRESS -> { | |
if (hitTestResult!!.node == null) { | |
Toast.makeText(this, "LONG PRESS performed", Toast.LENGTH_SHORT).show() | |
} | |
else { | |
Toast.makeText(this, "LONG PRESS performed on a node", Toast.LENGTH_SHORT).show() | |
} | |
} | |
else -> { } | |
} | |
gestureDetector.resetGestureType() | |
true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment