> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/reference/platform-concepts/event-handlers.md).

# Event handlers

Through the use of event handlers you can trigger an [action](https://docs.appfarm.io/reference/actions.md) to run either automatically or due to user interaction. Automatic events occur when an app is in use, such as when an [app](https://docs.appfarm.io/reference/apps.md) or [view](https://docs.appfarm.io/reference/apps/ui/views.md) is loaded, or a [timer](https://docs.appfarm.io/reference/apps/app-settings.md#timers). User interaction events can include clicking a [UI component](https://docs.appfarm.io/library/ui-components.md), updating a value in a data input component, or running a [keyboard shortcut](https://docs.appfarm.io/reference/apps/ui/views.md#keyboard-event-handlers).

{% hint style="info" %}
Showroom: [Hover and file drop example](https://showroom.appfarm.app/ui-components/hover), with its setup in Appfarm Create ([register](https://showroom.appfarm.app/sign-up) for access).
{% endhint %}

## Automatic events

| Event                                          | Description                                                                                                                                                                                                                                                                                                                       |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **On App Load**                                | Triggered when the app is loaded/refreshed after data sources have been populated but before the UI is shown to the user. Configured in [App settings](https://docs.appfarm.io/reference/apps/app-settings.md#event-handlers).                                                                                                    |
| **On App Loaded**                              | Triggered when the app is loaded/refreshed and after the UI is shown to the user. Configured in [App settings](https://docs.appfarm.io/reference/apps/app-settings.md#event-handlers).                                                                                                                                            |
| **On Online**/**On Offline**                   | For Offline Apps. Configured in [App settings](https://docs.appfarm.io/reference/apps/app-settings.md#event-handlers).                                                                                                                                                                                                            |
| **On Visible/On Hidden**                       | Triggered when an App goes inactive or active. Configured in [App settings](https://docs.appfarm.io/reference/apps/app-settings.md#event-handlers).                                                                                                                                                                               |
| **On Browser History Change**                  | Can be used to trigger an action when the browser history changes. Configured and documented in [App settings](https://docs.appfarm.io/reference/apps/app-settings.md#event-handlers).                                                                                                                                            |
| **On Timeout**                                 | Trigged when a timer expires. Configured in [App settings](https://docs.appfarm.io/reference/apps/app-settings.md#timers).                                                                                                                                                                                                        |
| **On View Load/Dialog Open**                   | Triggered before a [view](https://docs.appfarm.io/reference/apps/ui/views.md) or dialog is loaded/opened. Drawers have no event handler that runs before they open. Configured in [view properties](https://docs.appfarm.io/reference/apps/ui/views.md#event-handlers).                                                           |
| **On View Loaded/Dialog Opened/Drawer Opened** | Triggered after a [view](https://docs.appfarm.io/reference/apps/ui/views.md) is loaded/opened. Configured in [view properties](https://docs.appfarm.io/reference/apps/ui/views.md#event-handlers).                                                                                                                                |
| **On View Unload/Dialog Close**                | Triggered when a [view](https://docs.appfarm.io/reference/apps/ui/views.md) is unloaded or a dialog is closed. Not available on drawers. Configured in [view properties](https://docs.appfarm.io/reference/apps/ui/views.md#event-handlers).                                                                                      |
| **On Backdrop Click**                          | Triggered when the user clicks the backdrop or presses the `Escape` key. Available on dialogs with **Dismissible** selected, and on drawers of type `Temporary` or `Responsive` (only while the drawer is in temporary mode). Configured in [view properties](https://docs.appfarm.io/reference/apps/ui/views.md#event-handlers). |
| **On Load**                                    | Triggered after a component is loaded. Configured in component properties for Image and [Animated component](https://docs.appfarm.io/library/ui-components/animated-component.md).                                                                                                                                                |
| **On Complete**                                | Triggered after a component has completed its purpose. Configured in component properties for [Animated component](https://docs.appfarm.io/library/ui-components/animated-component.md).                                                                                                                                          |
| **On Loop**                                    | Triggered each time the animation is about to loop. Shown in component properties for [Animated component](https://docs.appfarm.io/library/ui-components/animated-component.md) when **Loop** is on.                                                                                                                              |

## User interaction events

User interaction events are configured in [UI components](https://docs.appfarm.io/library/ui-components.md). For details on how to add keyboard event handlers, see [Views](https://docs.appfarm.io/reference/apps/ui/views.md#keyboard-event-handlers).

| Event                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **On \[Location] Click** | Triggered when the user clicks or taps on a component (like a Button) or part of a component (like a Table row). Can be used to make containers and Image components clickable. If used in a data iterator, the element clicked will contain the [object in context](https://docs.appfarm.io/reference/platform-concepts/objects.md#object-in-context). Variants include **On Row Click** (Table, Data Grid), **On Cell Click** (Data Grid columns), **On Item Click** (List, Gantt chart), **On Action Click** (List), **On Delete Click** (Chip group) and **On Count Click** (Avatar group). |
| **On Hover Start**       | Triggered when the mouse pointer enters a container. Use [Conditional styles](https://docs.appfarm.io/reference/apps/ui/component-properties.md#conditional-style-properties) to style a component on hover.                                                                                                                                                                                                                                                                                                                                                                                    |
| **On Hover End**         | Triggered when the mouse pointer leaves a container.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| **On Double Click**      | Triggered when double clicking a container                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| **On Right Click**       | Triggered when right clicking a container                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| **On Drag Start**        | Triggered when a user starts to drag a component within a container that has **Draggable** selected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| **On Drag End**          | Triggered when a user stops dragging a component within a container that has **Draggable** selected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| **On Drop**              | Triggered when a user drops a component within a container that has **Drop area** selected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| **On File Paste**        | Triggered when a file is pasted on a container with **File drop** selected. Can be used to run an action with Create file object to upload the file.                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| **On File Drop**         | Triggered when a file is dropped on a container with **File drop** selected. Can be used to run an action with Create file object to upload the file.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **On File Over**         | Triggered when a file is dragged over a container with **File drop** selected. Can be used to toggle visual feedback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **On File Out**          | Triggered when a file is dragged over and then out of a container with **File drop** selected. Can be used to toggle visual feedback.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **On Viewport Enter**    | Triggered when a container with **Listener** selected enters the viewport, usually on scroll.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| **On Viewport Leave**    | Triggered when a container with **Listener** selected leaves the viewport, usually on scroll.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| **On Focus**             | Triggered when a Text edit component receives focus due to a user clicking on or using the keyboard to select the component.                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **On Lost Focus**        | Triggered when a Text edit component loses focus due to a user clicking away or using the keyboard to select another component.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| **On Enter**             | Triggered when the `Enter/Return` key is pressed and a Text edit component has focus. Useful when the component is used for searching to execute the search.                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **On Adornment Click**   | Available on Text edit when the adornment type is `Icon Button`. Triggered when the user clicks the adornment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| **On Value Change**      | Triggered after a value has changed in a data input component. The previous value can be sent as an action param. Slider, Switch and Checkbox label this event handler **On Value Changed**.                                                                                                                                                                                                                                                                                                                                                                                                    |
| **On Open**              | Available on UI Components [Select](https://docs.appfarm.io/library/ui-components/select.md) and [Multi select](https://docs.appfarm.io/library/ui-components/multi-select.md). Triggered when the droplist is opened.                                                                                                                                                                                                                                                                                                                                                                          |
| **On Close**             | Available on UI Components [Select](https://docs.appfarm.io/library/ui-components/select.md) and [Multi select](https://docs.appfarm.io/library/ui-components/multi-select.md). Triggered when the droplist is closed.                                                                                                                                                                                                                                                                                                                                                                          |
| **On Series Click**      | Available on advanced charts. Triggered when the user clicks a bar, point, or bubble. Sends the clicked point's series name and values as action params. See [Understand charts](https://docs.appfarm.io/how-to/user-interface/understand-charts.md#respond-to-clicks-with-on-series-click).                                                                                                                                                                                                                                                                                                    |
| **On Zoom**              | Available on Map, and on advanced line and combined charts with zoom enabled. Triggered after the user zooms. Values from the event, such as the zoom level, can be sent as action params.                                                                                                                                                                                                                                                                                                                                                                                                      |
| **On Item Changed**      | Available on Gantt chart. Triggered after an item is changed by drag and drop.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appfarm.io/reference/platform-concepts/event-handlers.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
