I’m creating a composable that has clickable subco...
# compose
r
I’m creating a composable that has clickable subcomponents. I want the root composable’s indicator to respond to the subcomponents’ interactions. This is what I have so far.
The problem I seem to be having is that the interaction is sending an offset relative to the clicked component rather than relative to the root component.
I’m a bit stuck in terms of googling around and digging deeper into the bowels of compose doesn’t seem to be yielding anything
l
Yes, the press position is relative to the clickable component. What is your expected behaviour here? Where would you want the ripple to appear from?
r
@Louis Pullen-Freilich [G] I would want the indicator coordinates to be relative to the root component. With the interaction offset being relative to the clickable component, the coordinates are actually incorrect for displaying the indicator on the root component. The indicator always appears very near to
0,0
in the root component.
l
You could have a second InteractionSource and manually convert the coordinates from the child components, to be relative to the root position, or use a pointer input modifier on the parent, and use that for the interactions, and ignore the children's interactions
r
I need to know about the children’s interactions because they are buttons with discrete behavior.
l
If so, it seems very unexpected that only the parent would show indication. Consider other states like focus, if one of the children is focused, then the whole row would appear focused and you wouldn't know which one is focused
r
That’s the design
The example that most easily comes to mind is a stepper control with a counter in the middle. The user wants to know that the whole stepper control has focus, not either of the buttons or the number display. But the way interaction detection appears to work is that unless a specific
Layout
is at the touch coordinates, it doesn’t receive the interaction. The equivalent in the old way is to delegate the click callback to the parent view until someone handles it.
l
Interactions are driven by the component that handles input events (clickable in this case), and emitted to the provided InteractionSource. There is no implicit interaction channel between components