Kshitij Patil
11/02/2020, 6:53 PMComposable
Box(Modifier.fillMaxSize()) {
Canvas(Modifier.clickable { Log.i(TAG, "Clicked") }) {
drawCircle(Color.Red, 25f, Offset(150f,150f))
}
}
I want only the portion of Circle clickable, I tried clipping the Canvas, didn't help. Canvas click events only work within Surface
, that too, on the entire Canvas area.romainguy
11/02/2020, 6:56 PMclickable()
can’t know what shape you want to restrict the click toromainguy
11/02/2020, 6:57 PMromainguy
11/02/2020, 6:57 PMromainguy
11/02/2020, 6:57 PMBox
but would inside a Surface
. @Adam Powell?Kshitij Patil
11/02/2020, 7:29 PMAdam Powell
11/02/2020, 7:31 PMCanvas(Modifier.fillMaxSize().clickable...)
Adam Powell
11/02/2020, 7:31 PMSurface
, cc @matvei for specific behavior differences thereKshitij Patil
11/02/2020, 7:56 PMfillMaxSize()
modifier on the Canvas.
Canvas
is not clickable unless it is preceded by the fillMaxSize
modifier. wrapContentSize
doesn't make any difference, so it seems like a compulsory step for the Canvas to have fillMaxSize()
modifier to be a clickableAndrey Kulikov
11/02/2020, 7:59 PMfillMaxSize()
, but any layout modifier. you can set some fixed size with `Modifier.size(48.dp)`In your case you had clickable area with 0x0 sizeAndrey Kulikov
11/02/2020, 8:00 PMKshitij Patil
11/02/2020, 8:02 PM