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

InputListener Interface

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.
When IsdkFeature is enabled, you should use onPointerEvent instead of onInput. More info here.
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)
}

Signature

interface InputListener

Functions

onClick ( receiver , hitInfo , sourceOfInput )
Called when a "click" is released while pointing at the object. This is a trigger release for controllers, and a pinch release for hands.
This method is invoked at the end of a click interaction, when the user releases a button that was pressed while pointing at the object. It's paired with InputListener.onClickDown, which is called when the button is initially pressed.
Signature
open fun onClick(receiver: SceneObject, hitInfo: HitInfo, sourceOfInput: Entity)
Parameters
receiver: SceneObject
The SceneObject receiving the click
hitInfo: HitInfo
Information about the ray intersection with the object
sourceOfInput: Entity
The Entity that is the source of the input (typically a controller)
onClickDown ( receiver , hitInfo , sourceOfInput )
Called when a "clickDown" is processed while pointing at the object. This is a trigger press for controllers, and a pinch for hands.
This method is invoked at the start of a click interaction, when the user presses a button while the pointer is over the object. It's paired with InputListener.onClick, which is called when the "click" is released.
Signature
open fun onClickDown(receiver: SceneObject, hitInfo: HitInfo, sourceOfInput: Entity)
Parameters
receiver: SceneObject
The SceneObject receiving the click
hitInfo: HitInfo
Information about the ray intersection with the object
sourceOfInput: Entity
The Entity that is the source of the input (typically a controller)
onHoverStart ( receiver , sourceOfInput )
Called when the pointer starts hovering over the object.
This method is invoked when a controller ray first enters the object's bounds. It's paired with InputListener.onHoverStop, which is called when the pointer leaves the object.
Signature
open fun onHoverStart(receiver: SceneObject, sourceOfInput: Entity)
Parameters
receiver: SceneObject
The SceneObject being hovered over
sourceOfInput: Entity
The Entity that is the source of the hover (typically a controller)
onHoverStop ( receiver , sourceOfInput )
Called when the pointer stops hovering over the object.
This method is invoked when a controller ray exits the object's bounds after previously hovering over it. It's paired with InputListener.onHoverStart, which is called when the pointer first enters the object.
Signature
open fun onHoverStop(receiver: SceneObject, sourceOfInput: Entity)
Parameters
receiver: SceneObject
The SceneObject that was being hovered over
sourceOfInput: Entity
The Entity that was the source of the hover (typically a controller)
onInput ( receiver , hitInfo , sourceOfInput , changed , buttonState , downTime ) : 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.
Hovering itself is considered an input event, but pressing and holding a button down will send input to the last focused object.
Signature
open fun onInput(receiver: SceneObject, hitInfo: HitInfo, sourceOfInput: Entity, changed: Int, buttonState: Int, downTime: Long): Boolean
Parameters
receiver: SceneObject
The SceneObject receiving the input
hitInfo: HitInfo
Information about the ray intersection with the object
sourceOfInput: Entity
The Entity that is the source of the input (typically a controller)
changed: Int
A bit mask indicating which buttons have changed state
buttonState: Int
A bit mask indicating the current state of all buttons
downTime: Long
The timestamp when the input interaction began (initial button change)
Returns
Boolean
True if the input was handled, false otherwise
onPointerEvent ( receiver , hitInfo , type , sourceOfInput , scrollInfo , semanticType )
Called for pointer events on the SceneObject.
Signature
open fun onPointerEvent(receiver: SceneObject, hitInfo: HitInfo, type: Int, sourceOfInput: Entity, scrollInfo: Vector2, semanticType: Int)
Parameters
receiver: SceneObject
The SceneObject receiving the pointer event
hitInfo: HitInfo
Information about the ray intersection with the object
type: Int
The type of pointer event (see PointerEventType)
sourceOfInput: Entity
The Entity that is the source of the input (typically a controller)
scrollInfo: Vector2
Vector containing scroll speeds in x and y directions
semanticType: Int
The semantic type of the event (see SemanticType)
stopInput ( receiver , sourceOfInput , downTime )
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.
Signature
open fun stopInput(receiver: SceneObject, sourceOfInput: Entity, downTime: Long)
Parameters
receiver: SceneObject
The SceneObject that was receiving input
sourceOfInput: Entity
The Entity controller that was the source of the input
downTime: Long
The timestamp when the input interaction began (last button change)
Did you find this page helpful?
Thumbs up icon
Thumbs down icon