---
title: "documentViewController(_:handleEvent:with:)"
framework: tvmlkit
role: symbol
role_heading: Instance Method
path: "tvmlkit/tvdocumentviewcontrollerdelegate/documentviewcontroller(_:handleevent:with:)"
---

# documentViewController(_:handleEvent:with:)

Handles events natively from document view controllers.

## Declaration

```swift
optional func documentViewController(_ documentViewController: TVDocumentViewController, handleEvent event: TVDocumentViewController.Event, with element: TVViewElement) -> Bool
```

## Discussion

Discussion By default, event handling can happen in either TVMLKit or TVMLKit JS. To defer event handling exclusively to TVMLKit JS, return false and don’t handle the event in this TVMLKit method. To assign event handling to TVMLKit, handle the event in this method and return true.
