I am creating a project where I have to move around Canvas elements(circles and lines) on drag gestures. I am using a Box composable to put different Canvas(s) inside it. And then with the help of pointerInput modifier I want to detect drag Gesture and hopefully achieve the behaviour I want.
Box(
modifier = Modifier
.fillMaxSize()
.padding(paddingValue),
contentAlignment = Alignment.Center
){
Canvas(modifier = Modifier
.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
change.consumeAllChanges()
centerOffSet = centerOffSet.plus(dragAmount)
}
}
) {
drawCircle(
color = Color.White,
center = centerOffSet,
radius = radiusValue
)
}
}
The problem I'm facing is that when I set the Canvas modifier to .matchParentSize() or .fillMaxSize(), I'm able to drag the circle but this makes the whole surface of the Box a touch target, which is not desired, using the .wrapContentSize() modifier is not working. Is there something I'm missing here?