Alex Styl
07/14/2024, 10:20 AMpointerInput(Unit){}
as some folks suggested and it's what Surface
uses internally, but it still lets the clicks go through its parents.
Chatgpt suggested to use detectTapGestures { }
inside of the pointerInput() and it does work (on desktop at least, havent tried others) but do I really need it? I want it to just block any kind of gestures. am i missing something?
Box(Modifier.clickable { error("Click parent") }.background(Color.Gray).fillMaxSize()) {
Box(Modifier.size(300.dp).background(Color.White).pointerInput(Unit) {}) { // this should consume clicks done to it, and not let 'parent' get clicks
Box(Modifier.size(48.dp).background(Color.Blue).clickable { println("👍 Clicking this is fine") })
}
}
Chrimaeon
07/14/2024, 11:43 AMSurface
is doing .pointerInput(Unit) {}
to prevent click to itself. not sure how your pointerInput
on a child should prevent the parent’s clickable
be called. It’s “empty” on Surface
so it doesn’t do anything.Chrimaeon
07/14/2024, 11:43 AMas some folks suggestedwhere is that?
Alex Styl
07/14/2024, 11:54 AMAlex Styl
07/14/2024, 11:55 AMChrimaeon
07/14/2024, 11:56 AMChrimaeon
07/14/2024, 11:58 AMAlex Styl
07/14/2024, 12:00 PMChrimaeon
07/14/2024, 12:02 PMAlex Styl
07/14/2024, 12:05 PMChrimaeon
07/14/2024, 12:08 PMAlex Styl
07/14/2024, 12:09 PMDan MacNeil
07/14/2024, 3:35 PM.pointerInput(Unit) {}
to
.pointerInput(Unit) {
detectTapGestures(onTap = { })
}
blocks the click from going to the parent. Is that what you are looking for?Alex Styl
07/14/2024, 3:40 PM