compose/remote/Documentation/parts/rc_click.md
RemoteCompose provides a flexible click system based on modifiers that can trigger both internal state changes and host-side callbacks.
Click events follow a similar propagation path to touch events but are specifically triggered on the "up" phase of a gesture if the movement threshold hasn't been exceeded.
CoreDocument)When a user clicks, CoreDocument.onClick(x, y) is called with root-relative coordinates.
Component)The document iterates through its component tree in reverse drawing order (top-to-bottom). For each component:
(x, y) is within the component's bounds via contains(x, y).onClick on its children.onClick handlers (usually via ComponentModifiers).Before reaching a ClickModifierOperation, the coordinates are transformed:
ClickModifierOperation)The primary way to make a component interactive is by adding a click modifier.
Easing.CUBIC_STANDARD and animates both color and radius over 1000ms.Role.BUTTON for accessibility services (e.g., TalkBack).A ClickModifierOperation acts as a container for one or more ActionOperations.
| Action Type | Description |
|---|---|
| ValueChange | Updates a RemoteCompose variable (Float, String, or Boolean). Useful for toggling states like isExpanded or clickCount. |
| HostAction | Sends a metadata string back to the host application (Android/iOS). This is used for navigation or triggering native logic. |
| Custom Actions | Can be implemented to perform complex sequences, such as multiple variable updates or conditional logic. |
The system ensures that clicks and scrolls don't conflict:
true, stopping further propagation to parent click handlers.