import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


[Event handlers](./advanced_collision_detection.mdx#collision-and-contact-force-events) are user-defined callbacks used to be
notified when two colliders start/stop touching. By default no collision event is generated by
the narrow-phase. In order to enable a collision event for a pair of colliders, at
least one of the involved colliders must have the corresponding event set as active. An event is activated for a collider
by setting its corresponding active events bit to `1`:
- Setting the <notjs>`ActiveEvents::COLLISION_EVENTS`</notjs><js>`ActiveEvents.COLLISION_EVENTS`</js> bit to 1
  enables the [collision events](./advanced_collision_detection.mdx#collision-and-contact-force-events) involving the collider.

The active events of a collider can be set when the collider is created or after its creation:

<rapier>

```rust
<load path='/2d/rust/examples/rs_colliders2.rs' marker='ActiveEvents1' />
```
```rust
<load path='/2d/rust/examples/rs_colliders2.rs' marker='ActiveEvents2' />
```

</rapier>
<bevy>

```rust
<load path='/2d/bevy/examples/colliders2.rs' marker='ActiveEvents1' />
```
```rust
<load path='/2d/bevy/examples/colliders2.rs' marker='ActiveEvents2' />
```

</bevy>
<js>

```js
<load path='/2d/javascript/src/snippets/colliders.ts' marker='ActiveEvents1' />
```
```js
<load path='/2d/javascript/src/snippets/colliders.ts' marker='ActiveEvents2' />
```

</js>