---
name: "ctrlSetPosition"
type: command
status: ok
groups: ["GUI Control - Positioning"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/ctrlSetPosition
revid: 373619
updated: 2025-05-25T10:19:49Z
---

# ctrlSetPosition

*Command · GUI Control - Positioning · Arma 3 v0.50 · introduced in Armed Assault v1.00*

## Description

Sets wanted position and size for 2D control animation. Width and height are optional. [ctrlCommit](../commands/ctrlCommit.md) is required to complete the operation.
For 3D control, param is relative `[x, z, y]` and no [ctrlCommit](../commands/ctrlCommit.md) is required as it cannot be animated. If target control is inside a CT_CONTROLS_GROUP, the position needs to be relative to it.

> [!IMPORTANT]
> This command doesn't work well with CT_MAP control. Use [ctrlMapSetPosition](../commands/ctrlMapSetPosition.md) instead.

## Syntax

### Syntax 1

```sqf
controlName ctrlSetPosition [x, y]
```

**Parameters:**

- `controlName`: [Control](../topics/Control.md) - 2D control
- `x`: [Number](../topics/Number.md) - position in x
- `y`: [Number](../topics/Number.md) - position in y

**Returns:** [Nothing](../topics/Nothing.md)

### Syntax 2

```sqf
controlName ctrlSetPosition [x, y, w, h]
```

**Parameters:**

- `controlName`: [Control](../topics/Control.md) - 2D control
- `x`: [Number](../topics/Number.md) - position in x
- `y`: [Number](../topics/Number.md) - position in y
- `w`: [Number](../topics/Number.md) - width of the control
- `h`: [Number](../topics/Number.md) - height of the control

**Returns:** [Nothing](../topics/Nothing.md)

### Syntax 3

```sqf
controlName ctrlSetPosition [x, z, y]
```

**Parameters:**

- `controlName`: [Control](../topics/Control.md) - 3D control
- `x`: [Number](../topics/Number.md) - screen x
- `z`: [Number](../topics/Number.md) - distance from the screen (depth). If object is too far, it cannot be dragged by the mouse.
- `y`: [Number](../topics/Number.md) - screen y

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

Move control:

```sqf
_control2D ctrlSetPosition [0, 0];
_control2D ctrlCommit 0;
```

### Example 2

Move control and resize:

```sqf
_control2D ctrlSetPosition [0, 0, 1, 1];
_control2D ctrlCommit 0;
```

### Example 3

```sqf
_control3D ctrlSetPosition [0.5, 1, 0.5]; //centered and 1m away from screen
```

### Example 4

Typewriter effect:

```sqf
with uiNamespace do
{
    0 spawn
    {
        _text1 = "This is a simple demo of typewriter text effect with various speed.";
        _text2 = "This took 10 seconds.";
        _text3 = "This is a fast one, set for 2 seconds.";

        ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1];

        ctrl ctrlSetPosition [0, 0, 0, 0.1];
        ctrl ctrlCommit 0;
        ctrl ctrlSetStructuredText parseText format ["<t color='#ff0000' size='2.1'>%1</t>", _text1 splitString " " joinString " "];
        ctrl ctrlSetPosition [0, 0, ctrlTextWidth ctrl, 0.1];
        ctrl ctrlCommit 8;

        waitUntil { ctrlCommitted ctrl };
        sleep 0.5;

        ctrl ctrlSetPosition [0,0,0,0.1];
        ctrl ctrlCommit 0;
        ctrl ctrlSetStructuredText parseText format ["<t color='#ff0000' size='2.1'>%1</t>", _text2 splitString " " joinString " "];
        ctrl ctrlSetPosition [0, 0, ctrlTextWidth ctrl, 0.1];
        ctrl ctrlCommit 2;

        waitUntil { ctrlCommitted ctrl };
        sleep 2;

        ctrl ctrlSetPosition [0,0,0,0.1];
        ctrl ctrlCommit 0;
        ctrl ctrlSetStructuredText parseText format ["<t color='#00ff00' size='2.1'>%1</t>", _text3 splitString " " joinString " "];
        ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1];
        ctrl ctrlCommit 2;

        waitUntil { ctrlCommitted ctrl };
        sleep 2;

        ctrlDelete ctrl;
    };
};
```

## See also

[ctrlMapSetPosition](../commands/ctrlMapSetPosition.md) · [ctrlCommit](../commands/ctrlCommit.md) · [ctrlCreate](../commands/ctrlCreate.md) · [ctrlDelete](../commands/ctrlDelete.md) · [ctrlModel](../commands/ctrlModel.md) · [ctrlSetModel](../commands/ctrlSetModel.md) · [ctrlPosition](../commands/ctrlPosition.md) · [ctrlClassName](../commands/ctrlClassName.md) · [displayCtrl](../commands/displayCtrl.md) · [ctrlModelScale](../commands/ctrlModelScale.md) · [ctrlSetModelScale](../commands/ctrlSetModelScale.md) · [ctrlModelDirAndUp](../commands/ctrlModelDirAndUp.md) · [ctrlSetModelDirAndUp](../commands/ctrlSetModelDirAndUp.md)

## Community notes

**Yuval** — 2017-06-20

If the target control is a controls' group, all the child controls of that group will be moved automatically (as their position is relative to the control group rather than the display).

<sub>Source: [BI Community Wiki — ctrlSetPosition](https://community.bistudio.com/wiki/ctrlSetPosition) (revision 373619).</sub>
