> ## 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.

# FormatView

A live preview of one document on one surface. Created by
`FileFormat.view`; disposed when its surface closes.

## Methods

### `draw`

<div class="signature">
  ```lua theme={null}
  draw(renderer: Renderer, width: number, height: number) -> ()
  ```
</div>

Draws the current frame into a viewport of width by height.

### `measure`

<div class="signature">
  ```lua theme={null}
  measure(viewportWidth: number, viewportHeight: number) -> (number, number)
  ```
</div>

Pane surfaces only: the content's intrinsic size for the given
viewport, driving the pane's scrollbars. Called when the view is
created, the document changes, the viewport resizes, or requestDraw
fires. Omit for fit-to-viewport views; the inspector never measures.

### `advance`

<div class="signature">
  ```lua theme={null}
  advance(seconds: number) -> boolean
  ```
</div>

Advances animation state. Return true to keep receiving frames.

### `textScrolled`

<div class="signature">
  ```lua theme={null}
  textScrolled(x: number, y: number, line: number, maxLine: number) -> ()
  ```
</div>

The user scrolled the text editor. x/y are scroll percentages and
line is the fractional top visible line. Never fired for scrolls the
host performed on the view's behalf (scrollEditorTo), so handlers can
follow without echo bookkeeping.

### `paneScrolled`

<div class="signature">
  ```lua theme={null}
  paneScrolled(x: number, y: number) -> ()
  ```
</div>

The user scrolled the preview pane (measured views only). x/y are the
new offsets in content coordinates. Never fired for scrolls the host
applied from `editor:scrollTo`.

### `paneWheel`

<div class="signature">
  ```lua theme={null}
  paneWheel(dx: number, dy: number) -> ()
  ```
</div>

Raw wheel/trackpad input over an unmeasured (self-scrolling) preview,
in pixels with positive y scrolling down. Implement to route pane
input into the view's own scrolling; without it the host falls back
to scrolling the paired text editor.

### `pointerDown`

<div class="signature">
  ```lua theme={null}
  pointerDown(event: PointerEvent) -> ()
  ```
</div>

Pointer input over the preview surface, in the same coordinate space
draw receives. Signatures match the Layout protocol so live artboards
can forward events directly (board:pointerDown(event), ...).

### `pointerMove`

<div class="signature">
  ```lua theme={null}
  pointerMove(event: PointerEvent) -> ()
  ```
</div>

### `pointerUp`

<div class="signature">
  ```lua theme={null}
  pointerUp(event: PointerEvent) -> ()
  ```
</div>

### `documentChanged`

<div class="signature">
  ```lua theme={null}
  documentChanged(doc: FormatDocument, parsed: buffer?) -> ()
  ```
</div>

Text documents only: the document changed; refresh derived state.

### `selectionChanged`

<div class="signature">
  ```lua theme={null}
  selectionChanged(line: number, column: number) -> ()
  ```
</div>

Text documents only: the primary cursor moved. line and column are
zero based code point coordinates.

### `dispose`

<div class="signature">
  ```lua theme={null}
  dispose() -> ()
  ```
</div>

The surface is closing; release resources.
