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
  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]
Signature
val dataModel: DataModel
eventName : String
[Get]
Signature
val eventName: String
handled : Boolean
[Get][Set]
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]
Signature
var throttleTime: Int?

Companion Object

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

Companion Object Functions

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
  A new ButtonDownEventArgs instance
Did you find this page helpful?