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

ButtonDownEventArgs

ButtonDownEventArgs

class ButtonDownEventArgs(val hitInfo: HitInfo, val button: ControllerButton, val dataModel: DataModel) : EventArgs
Event arguments for button press events.
ButtonDownEventArgs is used to pass information about a button press interaction through the event system. It contains a HitInfo object that provides details about the interaction, such as the hit point, normal, and distance, as well as the specific ControllerButton that was pressed.
This class is typically used when registering event listeners for button press events on entities, allowing components to respond to specific button inputs.
Example usage:
// Register a button press event listener on an entity
entity.registerEventListener<ButtonDownEventArgs>(ButtonDownEventArgs.EVENT_NAME) { entity, eventArgs ->
    // Handle the button press event
    val hitPoint = eventArgs.hitInfo.hitPoint
    val button = eventArgs.button

    // Perform actions based on which button was pressed
    when (button) {
        ControllerButton.A -> handleAButtonPress()
        ControllerButton.LeftTrigger -> handleLeftTriggerPress()
        // Handle other buttons...
    }
}

Constructors

NameSummary
ButtonDownEventArgs
constructor(hitInfo: HitInfo, button: ControllerButton, dataModel: DataModel)

Types

NameSummary
Companion
object Companion

Properties

NameSummary
button
val button: ControllerButton

The specific controller button that was pressed
dataModel
val dataModel: DataModel
eventName
val eventName: String
handled
var handled: Boolean
hitInfo
val hitInfo: HitInfo

Information about the hit/interaction that triggered the button press
throttleTime
var throttleTime: Int?

Companion

object Companion

Properties

NameSummary
EVENT_NAME
const val EVENT_NAME: String

The name of the button press event, used when registering event listeners.

Functions

NameSummary
fromHitInfo
fun fromHitInfo(hitInfo: HitInfo, dataModel: DataModel, changed: Int): ButtonDownEventArgs

Creates a ButtonDownEventArgs instance from a HitInfo object, DataModel, and button identifier.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon