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

ButtonDownEventArgs Class

Extends EventArgs
Modifiers: final
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...
    }
}

Signature

class ButtonDownEventArgs(val hitInfo: HitInfo, val button: ControllerButton, val dataModel: DataModel) : EventArgs

Constructors

ButtonDownEventArgs ( hitInfo , button , dataModel )
Signature
constructor(hitInfo: HitInfo, button: ControllerButton, dataModel: DataModel)
Parameters
hitInfo: HitInfo  Information about the hit/interaction that triggered the button press
button: ControllerButton  The specific controller button that was pressed
dataModel: DataModel  The data model associated with this event

Properties

[Get]
The specific controller button that was pressed
Signature
val button: ControllerButton
dataModel : DataModel
[Get]
Data model.
Signature
val dataModel: DataModel
eventName : String
[Get]
The string identifier for this event type, used to match registered Entity event listeners. Each EventArgs subclass defines its own event name constant for dispatch routing.
Signature
val eventName: String
handled : Boolean
[Get][Set]
Flag indicating whether this event has been consumed by a listener. Set to true in an event handler to prevent further propagation to other listeners registered for the same event.
Signature
var handled: Boolean
hitInfo : HitInfo
[Get]
Information about the hit/interaction that triggered the button press
Signature
val hitInfo: HitInfo
throttleTime : Int?
[Get][Set]
Minimum interval in milliseconds between consecutive dispatches of this event type. Events fired more frequently than this interval are silently dropped to prevent listener overload.
Signature
var throttleTime: Int?

Companion Object

Properties

EVENT_NAME : String
[Get]
The name of the button press event, used when registering event listeners.
Signature
const val EVENT_NAME: String

Methods

fromHitInfo ( hitInfo , dataModel , changed )
Creates a ButtonDownEventArgs instance from a HitInfo object, DataModel, and button identifier.
This factory method provides a convenient way to create ButtonDownEventArgs instances when sending events. It maps the raw button identifier (from ButtonBits) to the corresponding ControllerButton enum value.
Signature
fun fromHitInfo(hitInfo: HitInfo, dataModel: DataModel, changed: Int): ButtonDownEventArgs
Parameters
hitInfo: HitInfo  Information about the hit/interaction that triggered the button press
dataModel: DataModel  The data model associated with this event
changed: Int  The raw button identifier (from ButtonBits) that was pressed
Returns
ButtonDownEventArgs  A new ButtonDownEventArgs instance