# InteractionPolicy

Artifact: [androidx.xr.compose:compose](https://developer.android.com/jetpack/androidx/releases/xr-compose) [View Source](https://cs.android.com/search?q=file:androidx/xr/compose/subspace/layout/InteractionPolicy.kt+class:androidx.xr.compose.subspace.layout.InteractionPolicy) Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)


```
interface InteractionPolicy
```

<br />

*** ** * ** ***

Defines the `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy` for a spatial object. This policy enables reacting to a `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/SpatialInputEvent` from the user. An `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy` will not propagate to children, for example, an attached `https://developer.android.com/reference/kotlin/androidx/xr/compose/spatial/Orbiter.composable#Orbiter(androidx.xr.compose.spatial.ContentEdge.Horizontal,androidx.compose.ui.unit.Dp,androidx.xr.compose.spatial.OrbiterOffsetType,androidx.compose.ui.Alignment.Horizontal,androidx.xr.compose.subspace.layout.SpatialShape,androidx.compose.ui.unit.Dp,kotlin.Boolean,kotlin.Function0)`.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy#clickable(kotlin.Boolean,kotlin.Function0)(isEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` An `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy` that detects only click inputs |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy#onInputEvent(androidx.xr.compose.subspace.layout.SpatialInputEvent)(event: https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/SpatialInputEvent)` Raw event executed with every input update. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy#isEnabled()` Whether an interaction policy is enabled for this object. |

## Public companion functions

### clickable

Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)

```
fun clickable(isEnabled: Boolean = true, onClick: () -> Unit): InteractionPolicy
```

An `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy` that detects only click inputs

| Parameters |
|---|---|
| `isEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | Whether an interaction policy is enabled for this object. If `false`, click events will not be returned. |
| `onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Executed after a click occurs. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy` | an `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/InteractionPolicy` that filters for click events. |

## Public functions

### onInputEvent

Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)

```
fun onInputEvent(event: SpatialInputEvent): Unit
```

Raw event executed with every input update.

## Public properties

### isEnabled

Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)

```
val isEnabled: Boolean
```

Whether an interaction policy is enabled for this object. If `false`, spatial interaction input events will not be returned.