API reference
API reference
Select your platform
No SDKs available
No versions available

InputListener

InputListener

interface InputListener
Interface for handling input events on SceneObjects.
InputListener provides a comprehensive set of callback methods for responding to various input events such as clicks, hovers, and general pointer interactions.
SceneObject can have multiple InputListeners attached, allowing for modular input handling where different components can respond to the same input events independently.
Example usage:
// Create a custom input listener
val myInputListener = object : InputListener {
    override fun onClick(receiver: SceneObject, hitInfo: HitInfo, sourceOfInput: Entity) {
        // Handle click event
    }
}
// Attach the input listener to the SceneObject
val sceneObject = systemManager.findSystem<SceneObjectSystem>().getSceneObject(entity)
sceneObject?.thenAccept { so ->
   so.addInputListener(myInputListener)
}

Functions

NameSummary
onClick
open fun onClick(receiver: SceneObject, hitInfo: HitInfo, sourceOfInput: Entity)

Called when a "click" is released while pointing at the object. This is a trigger release for controllers, and a pinch release for hands.
onClickDown
open fun onClickDown(receiver: SceneObject, hitInfo: HitInfo, sourceOfInput: Entity)

Called when a "clickDown" is processed while pointing at the object. This is a trigger press for controllers, and a pinch for hands.
onHoverStart
open fun onHoverStart(receiver: SceneObject, sourceOfInput: Entity)

Called when the pointer starts hovering over the object.
onHoverStop
open fun onHoverStop(receiver: SceneObject, sourceOfInput: Entity)

Called when the pointer stops hovering over the object.
onInput
open fun onInput(receiver: SceneObject, hitInfo: HitInfo, sourceOfInput: Entity, changed: Int, buttonState: Int, downTime: Long): Boolean

Called when any input event occurs on the object. It provides raw button state information through bit masks that can be interpreted using ButtonBits constants.
onPointerEvent
open fun onPointerEvent(receiver: SceneObject, hitInfo: HitInfo, type: Int, sourceOfInput: Entity, scrollInfo: Vector2, semanticType: Int)

Called for pointer events on the SceneObject.
stopInput
open fun stopInput(receiver: SceneObject, sourceOfInput: Entity, downTime: Long)

Called when input interaction with a SceneObject stops. This will be called once the controller stops hovering, or if a button is held down, when the button is released.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon