---
name: "CT BUTTON"
type: topic
source: https://community.bistudio.com/wiki/CT_BUTTON
revid: 376760
updated: 2025-11-16T15:50:10Z
---

# CT BUTTON

### Introduction

Buttons are one way to add interactivity to your dialogs. If you need a button that has more options for customization then use [CT_SHORTCUTBUTTON](../topics/CT_SHORTCUTBUTTON.md).

> [!NOTE]
> If you want to add an image to the button check out [CT_SHORTCUTBUTTON](../topics/CT_SHORTCUTBUTTON.md) or [RscActivePicture](../topics/CT_ACTIVETEXT.md#rscactivepicture) instead.

#### Button States

The same button four times in different states:

| State | Description |
|---|---|
| **Enabled** | The button has not been [disabled](../commands/ctrlEnable.md), it currently doesn't have any mouse or keyboard related focus. |
| **Disabled** | The button has been explicitly disabled. It will not be clickable. |
| **Enabled** + **Focused** | As enabled; additionally it will have a small border of the color defined in the *colorFocused* property. This occurs when the button currently has focus (ie. is the default button or has been selected via the *Tab* key). |
| **Enabled** + **Active** | As enabled; additionally it will have a different background as specified in the *colorBackgroundActive* background. This occurs when the mouse is currently hovering over an unfocused button. |
| **Enabled** + **Active** + **Focused** | The combined result of the above two states. The mouse is currently hovering over the button in question and it has input focus. |

#### Reserved IDCs

- IDC = 1 for (contextually) OK or CONTINUE
- IDC = 2 for (contextually) CANCEL, ESCAPE or ABORT

> [!IMPORTANT]
> If you use these idc values, no action, script or event handler will operate on them.

#### Related commands & functions

- Commands: General
- Commands: UI Eventhandlers

#### Related User Interface Eventhandlers

- [Events: General](../topics/User_Interface_Event_Handlers.md#generic-events)
- [Events: Buttons](../topics/User_Interface_Event_Handlers.md#button-events)

### Alphabetical Order

> [!NOTE]
> TokenNames common to most controls, such as x, y, w, h, text, idc... can be found [**here**](../topics/Arma~3A_GUI_Configuration.md#common-properties).

> [!WARNING]
> Not all of the listed attributes might have an effect nor might the list be complete. All attributes were gathered with [this](https://github.com/7erra/BIKI.VR/blob/master/fnc/generateCTPage.sqf) config crawler.

```cpp
#define CT_BUTTON 1
```

#### A

##### action

**Type:** String

**Description:** Script command(s) to execute when button is pressed. Must use double quotes; single quotes or curly brackets will not work.

The variable "_this" was available until Arma 3 v2.18 and contained an empty string. From Arma 3 v2.18, it is not available anymore.

> [!IMPORTANT]
> - Unlike User Interface Event Handlers no "_this" information about the current control is passed.
> - It is recommended to use [onButtonClick](../topics/User_Interface_Event_Handlers.md#onbuttonclick) instead.

```cpp
action = "BIS_SyndikatAgent setVariable ['State', 1];";
```

##### autocomplete

**Type:** Number

**Description:** Should not apply to this control, rather it is used on [CT_EDIT](../topics/CT_EDIT.md).

```cpp
autocomplete = 0;
```

#### B

##### borderSize

**Type:** Number

**Description:** If > 0 then a background (in the color defined in 'colorBorder') is drawn behind the button. It extends to the left by the distance defined here, its height is slightly less than that of the button, and it is vertically centered. The width extends to the right, to where the drop shadow starts. Stays static when button is pressed.

```cpp
borderSize = 0;
```

#### C

##### canModify

**Type:** Number

**Description:** Should not apply.

```cpp
canModify = 1;
```

##### color

**Type:** Array

**Description:** n/a

```cpp
color[] = {0,0,0,0};
```

##### colorActive

**Type:** Array

**Description:** n/a

```cpp
colorActive[] = {0,0,0,0};
```

##### colorBackgroundActive

**Type:** Array

**Description:** Background color if "active" (i.e. mouse pointer is over it).

```cpp
colorBackgroundActive[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.77])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.51])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.08])",1};
```

##### colorBackgroundDisabled

**Type:** Array

**Description:** Background color if control is disabled.

```cpp
colorBackgroundDisabled[] = {0,0,0,0.5};
```

##### colorBorder

**Type:** Array

**Description:** n/a

```cpp
colorBorder[] = {0,0,0,1};
```

##### colorFocused

**Type:** Array

**Description:** Alternating background color. While the control has focus (but without the mouse pointer being over it) the background will cycle between 'colorFocused' and 'colorBackground' or, if defined, 'colorFocused2'. If both are the same, then the color will be steady.

```cpp
colorFocused[] = {0,0,0,1};
```

##### colorFocused2

**Type:** Array

**Description:** n/a

```cpp
colorFocused2[] = {1,1,1,0.1};
```

##### colorSelection

**Type:** Array

**Description:** Should not apply.

```cpp
colorSelection[] = {0.47,0.49,0.47,0.93};
```

##### colorShadow

**Type:** Array

**Description:** Color of drop shadow behind button (not visible if button disabled or foreground color) has an alpha of 1.

```cpp
colorShadow[] = {0,0,0,0};
```

#### I

##### idcx

**Type:** Number

**Description:** Used in the Arsenal display for some reason.

```cpp
idcx = 912;
```

#### K

##### KeyHints

**Type:** Class

**Description:** n/a

```cpp
class KeyHints
{
    class A
    {
        key = "0x00050000 + 0";
        hint = "KEY_XBOX_A";
    };
};
```

#### O

##### offsetPressedX

**Type:** Number, String

**Description:** The button's text & background will move by this distance horizontally when pressed. Distance is in [UI Coordinates](../topics/GUI_Coordinates.md).

(If a shadow is defined, it will stay in place.)
Number example:

```cpp
offsetPressedX = 0;
```

String example:

```cpp
offsetPressedX = "pixelW";
```

##### offsetPressedY

**Type:** Number, String

**Description:** The button's text & background will move by this distance vertically when pressed. Distance is in [UI Coordinates](../topics/GUI_Coordinates.md).

(If a shadow is defined, it will stay in place.)
Number example:

```cpp
offsetPressedY = 0;
```

String example:

```cpp
offsetPressedY = "pixelH";
```

##### offsetX

**Type:** Number

**Description:** Horizontal offset of drop shadow.

If 0, then shadow will be placed directly behind button.

```cpp
offsetX = 0;
```

##### offsetY

**Type:** Number

**Description:** Vertical offset of drop shadow.

If 0, then shadow will be placed directly behind button.

```cpp
offsetY = 0;
```

#### P

##### period

**Type:** Number

**Description:** Defines how fast the button is oscillating between the colorActive and colorBackground while it is active.

```cpp
period = 0;
```

##### periodFocus

**Type:** Number

**Description:** n/a

```cpp
periodFocus = 2;
```

##### periodOver

**Type:** Number

**Description:** n/a

```cpp
periodOver = 0;
```

#### S

##### shortcuts

**Type:** Array

**Description:** Key shortcuts. Often overwritten/ignored by engine.

```cpp
shortcuts[] = {"512 + 0x20"};
```

##### soundClick

**Type:** Array

**Description:** Sound array played when the button is clicked and released.

- file path
- volume
- pitch

```cpp
soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0.09,1};
```

##### soundEnter

**Type:** Array

**Description:** Sound array played when the mouse enters the button's area.

```cpp
soundEnter[] = {"\A3\ui_f\data\sound\RscButton\soundEnter",0.09,1};
```

##### soundEscape

**Type:** Array

**Description:** n/a

```cpp
soundEscape[] = {"\A3\ui_f\data\sound\RscButton\soundEscape",0.09,1};
```

##### soundPush

**Type:** Array

**Description:** Sound array played when the button is pushed down.

```cpp
soundPush[] = {"\A3\ui_f\data\sound\RscButton\soundPush",0.09,1};
```

#### U

##### url

**Type:** String

**Description:** URL which will be opened with default web browser. If tooltip is empty, URL will also be set as that. URL must contain `http(s)://`.

> [!NOTE]
> See [Description.ext - CfgCommands](../topics/Description.ext.md#cfgcommands) to allow URLs.

```cpp
url = "";
```

### Default Classes

> [!NOTE]
> **Arma 3:** **AddOns:** Classes need to be initialised first with `class SomeClass;`
>
> ---
>
> **Missions:** Since Arma 3 v2.02 one can use `import SomeClass;` to initialise a class (see the [import](../topics/import_~28Config~29.md) keyword).
>
> In older versions, use `"Default" call BIS_fnc_exportGUIBaseClasses;` and paste the result into the [description.ext](../topics/Description.ext.md).

#### RscButton

```cpp
class RscButton
{
    deletable = 0;
    fade = 0;
    access = 0;
    type = CT_BUTTON;
    text = "";
    colorText[] = {1,1,1,1};
    colorDisabled[] = {1,1,1,0.25};
    colorBackground[] = {0,0,0,0.5};
    colorBackgroundDisabled[] = {0,0,0,0.5};
    colorBackgroundActive[] = {0,0,0,1};
    colorFocused[] = {0,0,0,1};
    colorShadow[] = {0,0,0,0};
    colorBorder[] = {0,0,0,1};
    soundEnter[] =
    {
        "\A3\ui_f\data\sound\RscButton\soundEnter",
        0.09,
        1
    };
    soundPush[] =
    {
        "\A3\ui_f\data\sound\RscButton\soundPush",
        0.09,
        1
    };
    soundClick[] =
    {
        "\A3\ui_f\data\sound\RscButton\soundClick",
        0.09,
        1
    };
    soundEscape[] =
    {
        "\A3\ui_f\data\sound\RscButton\soundEscape",
        0.09,
        1
    };
    idc = -1;
    style = ST_CENTER;
    x = 0;
    y = 0;
    w = 0.095589;
    h = 0.039216;
    shadow = 2;
    font = "RobotoCondensed";
    sizeEx = GUI_TEXT_SIZE_MEDIUM;
    url = "";
    offsetX = 0;
    offsetY = 0;
    offsetPressedX = 0;
    offsetPressedY = 0;
    borderSize = 0;
};
```

#### RscButtonTextOnly

Nothing but text. No background, no oscillating color.

```cpp
class RscButtonTextOnly : RscButton
{
    SizeEx = GUI_TEXT_SIZE_SMALL;
    colorBackground[] = { 1, 1, 1, 0 };
    colorBackgroundActive[] = { 1, 1, 1, 0 };
    colorBackgroundDisabled[] = { 1, 1, 1, 0 };
    colorFocused[] = { 1, 1, 1, 0 };
    colorShadow[] = { 1, 1, 1, 0 };
    borderSize = 0;
};
```

<sub>Source: [BI Community Wiki — CT BUTTON](https://community.bistudio.com/wiki/CT_BUTTON) (revision 376760).</sub>
