Closed cybercoder-naj closed 3 months ago
The current workaround is having a local state to keep the size. Wondering if the library can do this without it.
@Composable
fun Component() {
var canvasSize by remember { mutableStateOf(Size.Unspecified) }
Canvas(
modifier = Modifier
/* look previous comment */
) {
canvasSize = size
/* drawing elements */
}
}
you can use PointerInputScope function for this as
Modifier.pointerInput(Unit){
val size = size
detectMotionEvents(
onDown = {
},
onMove = {
},
onUp = {
}
)
}
I am working on the Canvas object such as follows:
Do you think adding something to the modifier with the size of the Canvas would be possible? If the user is pressing "Down" on the canvas, it is useful to know where it is with respect to the dimensions of the canvas.