---
name: "onHCGroupSelectionChanged"
type: command
status: ok
groups: ["High Command", "Event Handlers"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/onHCGroupSelectionChanged
revid: 369345
updated: 2024-09-03T18:43:02Z
---

# onHCGroupSelectionChanged

*Command · High Command, Event Handlers · Arma 3 v0.50 · introduced in Arma 2 v1.00*

## Description

Defines an action performed when high command group selection has been changed.

Command receives 2 variables:
- _group: [Group](../topics/Group.md) - last selected/deselected group
- _isSelected: [Boolean](../topics/Boolean.md) - new selection state of the specific group
The code is executed on every hc group selection change until it is replaced or removed (see [#Example 3](../commands/onHCGroupSelectionChanged.md#example-3)).

> [!IMPORTANT]
> Using the command again will **overwrite** the previously set code.

> [!NOTE]
> Since Arma 3 v1.58 a stackable version of this EH is available: [HCGroupSelectionChanged](../topics/Mission_Event_Handlers.md#hcgroupselectionchanged)

## Syntax

```sqf
onHCGroupSelectionChanged code
```

**Parameters:**

- `code`: [String](../topics/String.md) or [Code](../topics/Code.md)

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

## Examples

### Example 1

```sqf
onHCGroupSelectionChanged {
    if (_isSelected) then
    {
        hint format ["Group %1 has been selected.", _group];
    }
    else
    {
        hint format ["Group %1 has been deselected.", _group];
    };
};
```

### Example 2

```sqf
onHCGroupSelectionChanged "player globalChat 'HC group selection has been changed.';";
```

### Example 3

Remove event handler:

```sqf
onHCGroupSelectionChanged "";
// or
onHCGroupSelectionChanged {};
```

## See also

High Command · [hcAllGroups](../commands/hcAllGroups.md) · [hcGroupParams](../commands/hcGroupParams.md) · [hcLeader](../commands/hcLeader.md) · [hcRemoveAllGroups](../commands/hcRemoveAllGroups.md) · [hcRemoveGroup](../commands/hcRemoveGroup.md) · [hcSelected](../commands/hcSelected.md) · [hcSelectGroup](../commands/hcSelectGroup.md) · [hcSetGroup](../commands/hcSetGroup.md) · [hcShowBar](../commands/hcShowBar.md) · [hcShownBar](../commands/hcShownBar.md) · [onCommandModeChanged](../commands/onCommandModeChanged.md)

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