Skip to main content

Events

APIs for pointer interactions and action triggers.


PointerEvent

Pointer interaction event data.

Constructor

PointerEvent.new(id, position)

Creates a new PointerEvent. Used for forwarding events to nested artboards.

PointerEvent.new(id: number, position: Vector): PointerEvent

Example:

-- Forward event to nested artboard
local childPos = transformToChildSpace(event.position)
local childEvent = PointerEvent.new(event.id, childPos)

Attributes

AttributeTypeDescription
positionVectorLocal coordinates
idnumberPointer ID (for multitouch)

Methods

event:hit(isTranslucent?)

Marks the event as handled. If isTranslucent is true, the event may continue to propagate through translucent hit targets.

event:hit()              -- Standard: stops propagation
event:hit(true) -- Translucent: may continue through

Example:

function pointerDown(self, event: PointerEvent)
if isInBounds(event.position) then
self.pressed = true
event:hit()
end
end

Trigger

A type alias used in Input<T> declarations to mark a trigger input.

export type Trigger = (any) -> ()

In practice, triggers are accessed via viewModel:getTrigger(...), which returns a PropertyTrigger with fire() and listener methods. The Trigger type itself is primarily used when declaring Input<Trigger> fields on script types.

See Also: PropertyTrigger

Next Steps