<!--
{
  "availability" : [
    "tvOS: 13.0.0 - 18.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "TVMLKit",
  "identifier" : "/documentation/TVMLKit/TVDocumentViewControllerDelegate/documentViewController(_:handleEvent:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "TVMLKit"
    ],
    "preciseIdentifier" : "c:objc(pl)TVDocumentViewControllerDelegate(im)documentViewController:handleEvent:withElement:"
  },
  "title" : "documentViewController(_:handleEvent:with:)"
}
-->

# documentViewController(_:handleEvent:with:)

Handles events natively from document view controllers.

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

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)