> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/code/gum-code-reference/interactivegue/click.md).

# Click

## Introduction

A Click event is raised when an InteractiveGue is first pressed, then released. This can occur with a mouse cursor or a touch screen press/release.

The Click event is used by most Gum Forms controls to raise their own Click event, and to update visual state.

## Click Definition

A click occurs when the following happens:

1. The user presses on the InteractiveGue (touch or mouse button not down last frame, is down this frame)
2. The user releases on the same InteractiveGue (touch or mouse button was down last frame, is not down this frame)

{% hint style="info" %}
Some UI elements should react immediately when pressed rather than waiting for the cursor to be released. For this type of behavior, see the Push event. For more information, see the [Push event page](/gum/code/gum-code-reference/interactivegue/push.md).
{% endhint %}

For simplicity the following code can be used to test click events:

```csharp
// Initialize
var button = new Button();
button.AddToRoot();
button.Anchor(Gum.Wireframe.Anchor.Center);

// Button's Click event internally uses an InteractiveGue's Click, so
// we can test when clicks are raised by subscribing to a Button's Click
button.Click += (_, _) =>
    button.Text = DateTime.Now.ToString();
```

Clicking (pressing, then releasing) on the button raises the Click event which updates the button's text. Notice that the click is raised on release, and that the cursor can move away from the initial press location so long as it is still within the bounds of the same pressed instance.

<figure><img src="/files/EoAl9gE8aOn60CA34jrS" alt=""><figcaption><p>Button pressed then released causing a Click event to be raised</p></figcaption></figure>

A click is even raised if the press happens on the button, the cursor is moved off of the button, then moved back on the button before being released.

<figure><img src="/files/uPVggaJeUq4GznueHsFD" alt=""><figcaption><p>Click event still raised even if the cursor moves off of the instance temporarily</p></figcaption></figure>

If the moue button is pressed when not hovering over the instance, then a click is not raised even if the user released the mouse over the instance.

<figure><img src="/files/6195LpTgQ3tTzSFPpbsS" alt=""><figcaption><p>Click event is not raised if the user presses while off of the button, then drags on</p></figcaption></figure>


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/gum/code/gum-code-reference/interactivegue/click.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
