---
id: "T:cAlgo.API.ButtonClickEventArgs"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/EventArgs/ButtonClickEventArgs/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# ButtonClickEventArgs (class)

Represents the button click event data.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Never raised in the CLI: the events that pass it never fire there (Button.Click).
- Cloud: Never raised in the cloud: the events that pass it never fire there (Button.Click).

## Definition

```csharp
public class ButtonClickEventArgs
```

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // This example shows how to use the Button object Click event ButtonClickEventArgs
    public partial class ButtonClickEventArgsSample : Indicator
    {
        protected override void Initialize()
        {
            var button = new Button
            {
                Text = "Button not clicked yet",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };

            // Whenever you click on the button the Button_Click method will be called
            button.Click += Button_Click;

            Chart.AddControl(button);
        }

        // Here we change the button test when it is clicked
        private void Button_Click(ButtonClickEventArgs obj)
        {
            obj.Button.Text = "Button Clicked";
        }

        public override void Calculate(int index)
        {
        }
    }
}
```

Python:

```python
import clr
clr.AddReference("cAlgo.API")

from cAlgo.API import *

class Test():
    def initialize(self):
        button = Button()
        button.Text = "Button not clicked yet"
        button.HorizontalAlignment = HorizontalAlignment.Center
        button.VerticalAlignment = VerticalAlignment.Center

        # Whenever you click on the button the on_button_click method will be called
        button.Click += self.on_button_click

        api.Chart.AddControl(button)

    def on_button_click(self, args):
        # Here we change the button test when it is clicked
        args.Button.Text = "Button Clicked"
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true
}
```

## Properties

- `public Button Button {get;}` — Gets the button data. [details](https://help.ctrader.com/ctrader-algo/references/EventArgs/ButtonClickEventArgs/Button/index.md)

