# Button

### Introduction

Button is a standard clickable object with states for enabled (default), hover, pressed, and disabled.

<figure><img src="/files/erqJ4Z1erOR47lFIrU4b" alt=""><figcaption></figcaption></figure>

### Layout Requirements

The Button control has no requirements - an empty container is sufficient.

![](/files/MH3DwiilIDeCCWVQwUzP)

### TextInstance

The Button control can optionally include a Text instance named **TextInstance**. Setting the Button control's **Text** property changes the **TextInstance's** displayed string.

![](/files/6mj6CGqAjSApA62t0yNE)

### Code Example

Buttons provide events for Click and Push events. The following code shows how to handle these events on a button obtained from a gum runtime object named **ButtonInstance**:

```lang:c#
void CustomInitialize()
{

    var button = TutorialScreenGum
        .GetGraphicalUiElementByName("ButtonInstance")
        .FormsControlAsObject as Button;

    button.Click += HandleButtonClick;
    button.Push += HandleButtonPush;
}

private void HandleButtonClick(object sender, EventArgs e)
{
    // handle click logic here
}

private void HandleButtonPush(object sender, EventArgs e)
{
    // handle push logic here
}
```

### Code Example - Code-Only Creation

```lang:c#
void CustomInitialize()
{
    // This will construct a button using the default
    // visual which should be set-up by Glue, or which can be
    // manually set up in code.
    var button = new Button();
    button.Visual.AddToManagers();
    button.Text = "Hello";
    button.Click += HandleButtonClick;
    button.Push += HandleButtonPush;
}

private void HandleButtonClick(object sender, EventArgs e)
{
    // handle click logic here
}

private void HandleButtonPush(object sender, EventArgs e)
{
    // handle push logic here
}
```


---

# Agent Instructions: 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:

```
GET https://docs.flatredball.com/flatredball/api/flatredball-forms/controls/button.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
