Arkadii Ivanov
06/15/2023, 7:44 PMscale(0.5F)
+ pointerInput
then gestures are detected outside of the visible bounds (like scale
is ignored). Is there any way of handling gestures only inside visible bounds? Code in the thread.Arkadii Ivanov
06/15/2023, 7:45 PMBox(
modifier = Modifier
.requiredSize(128.dp)
.scale(0.5F)
.background(Color.Red)
.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
println(change)
change.consume()
}
},
)
Tried different order of the modifiers, but it didn't help.mohamed rejeb
06/15/2023, 7:57 PMvar size by remember { mutableStateOf(Size.Zero) }
var topLeft by remember { mutableStateOf(Offset.Zero) }
Box(
modifier = Modifier
.requiredSize(128.dp)
.scale(0.5F)
.onGloballyPositioned {
size = it.size.toSize()
topLeft = it.localToRoot(Offset.Zero)
}
.background(Color.Red)
.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
if (
change.position.x !in topLeft.x..(topLeft.x + size.width) ||
change.position.y !in topLeft.y..(topLeft.y + size.height)
) return@detectDragGestures
change.consume()
text = change.toString()
}
},
) {
Text(text = text)
}
Alexander Zhirkevich
06/16/2023, 7:35 AMArkadii Ivanov
06/16/2023, 7:46 AMAlexander Zhirkevich
06/16/2023, 7:46 AMIvan Matkov
06/16/2023, 8:07 AM1.4.*
patch, we'll release it soon (there are some issues with it, so no specific date)Ivan Matkov
06/23/2023, 10:56 AMArkadii Ivanov
06/23/2023, 2:30 PMIvan Matkov
06/23/2023, 2:36 PMArkadii Ivanov
06/23/2023, 2:54 PMIvan Matkov
06/23/2023, 2:58 PM