Skip to main content
Represents a pointer interaction event containing position and pointer id.

Fields

position

The position of the pointer in local coordinates.
function handlePointerDown(self: RenderInstance, event: PointerEvent)
  if self.instance then
    local localPos = event.position - Vector.xy(self.x, self.y)
    local localEvent = PointerEvent.new(event.id, localPos)
    local hit = self.instance:pointerDown(localEvent)
    if hit ~= 0 then
      print(
        string.format(
          'Local hit at (%.1f, %.1f)',
          localEvent.position.x,
          localEvent.position.y
        )
      )
    end
  end
end

id

The unique identifier for the pointer.
function handlePointerDown(self: RenderInstance, event: PointerEvent)
  if self.instance then
    local localPos = event.position - Vector.xy(self.x, self.y)
    local localEvent = PointerEvent.new(event.id, localPos)
    local hit = self.instance:pointerDown(localEvent)
    if hit ~= 0 then
      print(localEvent.id)
    end
  end
end

type

The type of event (pointerDown, pointerUp, click, pointerEnter, pointerMove, etc).

Constructors

new

new(id: number, position: Vector) -> PointerEvent
Creates a new PointerEvent with the given id and position.
function handlePointerDown(self: RenderInstance, event: PointerEvent)
  if self.instance then
    local localPos = event.position - Vector.xy(self.x, self.y)
    local localEvent = PointerEvent.new(event.id, localPos)
    local hit = self.instance:pointerDown(localEvent)
    if hit ~= 0 then
      print(
        string.format(
          'Local hit at (%.1f, %.1f)',
          localEvent.position.x,
          localEvent.position.y
        )
      )
    end
  end
end

Methods

hit

hit(isTranslucent: boolean?) -> ()
Marks the event as handled. If isTranslucent is true, the event may continue to propagate through translucent hit targets.
function handlePointerDown(self: PointerExample, event: PointerEvent)
  if self.instance then
    local hit = self.instance:pointerDown(event)
    if hit ~= 0 then
      -- Mark as handled but still allow translucent targets behind to receive it.
      event:hit(true)
    end
  end
end