movable
public fun SubspaceModifier.movable(
enabled: Boolean = true,
scaleWithDistance: Boolean = true,
onMove: ((SpatialMoveEvent) -> Unit),
): SubspaceModifier
Configures this subspace element to accept move events and report the calculated pose updates via a callback, without automatically applying a resulting transformation.
When the movable modifier is present and enabled, draggable UI controls will be shown that allow the user to move the element in 3D space. This modifier enables custom behavior for movement of the content. The system calculates the target Pose based on input, but does not automatically apply it to the associated layout. The developer is responsible for consuming the onMove event and applying the result. (e.g., by updating a state backed by SubspaceModifier.offset)
There are some limitations that should be considered when using this modifier: 1) the draggable UI controls of nested composables using the transformingMovable modifier and movable modifier may conflict with each other, 2) It cannot be used with the following composables androidx.xr.compose.subspace.SpatialExternalSurfaceHemisphere and androidx.xr.compose.subspace.SpatialExternalSurfaceSphere due to their similarity with the system environment and not having any layout size.
Parameters
| enabled | true if this composable should be movable. Setting this to false will remove the interactable affordance associated with the content. Disabling the modifier after movement keeps the composable at its last dragged position. Removing the modifier entirely resets the composable to its original layout position. |
| scaleWithDistance | true if this composable should scale in size when moved in depth. When enabled, the subspace element will grow if pushed away from the user or shrink when pulled toward the user in order to maintain the interact-ability and legibility of the panel. Scaling with distance respects other transformations applied to this layout. |
| onMove | callback invoked continuously during the interaction that receives a SpatialMoveEvent containing the calculated target pose, scale, and size. The pose contained in this event is the sum of all previous events in the move gesture. The receiver MUST use this data to update the element's external state to reflect movement. |
movable
Deprecated
This modifier is deprecated. Use transformingMovable() for default system-handled movement that automatically applies transformations to the layout. For custom movement where you manually apply the resulting pose (e.g., via offset), use the updated movable() modifier signature.
public fun SubspaceModifier.movable(
enabled: Boolean = true,
stickyPose: Boolean = false,
scaleWithDistance: Boolean = true,
onMoveStart: ((SpatialMoveEvent) -> Unit)? = null,
onMoveEnd: ((SpatialMoveEvent) -> Unit)? = null,
onMove: ((SpatialMoveEvent) -> Boolean)? = null,
): SubspaceModifier
When the movable modifier is present and enabled, draggable UI controls will be shown that allow the user to move the element in 3D space.
There are some limitations that should be considered when using this modifier: 1) the draggable UI controls of nested composables using the movable modifier may conflict with each other, 2) when attaching multiple movable modifiers that handle movement internally, the movement effect will be compounded.
Parameters
| enabled | true if this composable should be movable. |
| stickyPose | if enabled, the user specified position will be retained when the modifier is disabled or removed. |
| scaleWithDistance | true if this composable should scale in size when moved in depth. When this scaleWithDistance is enabled, the subspace element moved will grow or shrink. It will also maintain any explicit scale that it had before movement. |
| onMoveStart | a callback to process the start of a move event. This will only be called if enabled is true. |
| onMoveEnd | a callback to process the end of a move event. This will only be called if enabled is true. |
| onMove | a callback to process the pose change during movement, with translation in pixels. This will only be called if enabled is true. If the callback returns false the default behavior of moving this composable's subspace hierarchy will be executed. If it returns true, it is the responsibility of the callback to process the event. |