Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Type:ButtonEventHandler

From Resonite Wiki

ButtonEventHandler is a delegate type for methods that react to a button event. A method that can be bound to it takes the button that raised the event and a ButtonEventData that describes where the button was touched, and returns nothing. Its generic form, ButtonEventHandler<T>, takes one extra argument of type T after those two.

The type is used for the synced delegate fields of buttons (Pressed, Pressing, Released and, on some, the hover events) and of the relay components that call a method when a button is pressed. Such a field is a SyncDelegate of this type, so it can point at any method with a matching signature on any component in the world, and the target is saved with the world. The same type is also used for the local-only events of the C# side of a button, which cannot be saved.

Signature

Parameter Type Description
button IButton The button that raised the event.
eventData ButtonEventData Where and by what the button was touched.
argument T Only on ButtonEventHandler<T>. The value stored in the Argument field of the relay that calls the method.

ButtonEventData

Member Type Description
source Component The component that caused the event, such as the touching laser or finger.
globalPoint Float3 Point of the touch in global space.
localPoint Float2 Point of the touch in the local space of the button.
normalizedPressPoint Float2 Point of the touch relative to the size of the button.

Where it is used

Button events (ButtonEventHandler)

Component Fields of this type
Button Pressed, Pressing, Released, HoverEnter, HoverStay, HoverLeave
LegacyButton Pressed, Pressing, Released
PhysicalButton Pressed, Pressing, Released
TouchButton Pressed, Pressing, Released
ContextMenuItemSource Pressed, Pressing, Released

These components all implement IButton, which declares Pressed, Pressing and Released as synced delegates of this type.

Relays (ButtonEventHandler)

Component Fields of this type Behavior
ButtonRelay ButtonPressed Calls the target when a button it is attached to is pressed.
ButtonHoverRelay OnHoverEnter, OnHoverStay, OnHoverLeave Calls the targets for the hover events.

Relays with an argument (ButtonEventHandler<T>)

All of these call ButtonPressed when pressed and pass the value of their Argument as the third parameter.

Component Type of Argument
ButtonRelay<T> T (a value type)
ButtonRefRelay<T> A reference to a T (any world element)
ButtonDelegateRelay<T> A delegate of type T

The relays also share the DoublePressDelay and ReleasePressInterval fields, which delay or filter when the target is called.

ProtoFlux

The ButtonEvents node subscribes to the Pressed, Pressing, Released, HoverEnter, HoverStay and HoverLeave events of a button and gives out the data of the event (source, global point, local point and normalized point) as outputs.

See also