> ## Documentation Index
> Fetch the complete documentation index at: https://rive.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PointerEvent

Represents a pointer interaction event containing position and pointer id.

## Fields

### `position`

The position of the pointer in local coordinates.

```lua highlight={10,11} theme={null}
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.

```lua highlight={7} theme={null}
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`

<div class="signature">
  ```lua theme={null}
  new(id: number, position: Vector) -> PointerEvent
  ```
</div>

Creates a new [PointerEvent](/scripting/api-reference/artboards/pointer-event) with the given id and position.

```lua highlight={4} theme={null}
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`

<div class="signature">
  ```lua theme={null}
  hit(isTranslucent: boolean?) -> ()
  ```
</div>

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

```lua highlight={6} theme={null}
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
```
