detectTapGestures returns the expected onTap / onPress asset when TalkBack is disabled, however, when TalkBack is enabled, the offset being returned is a constant in the center of the view.
Jetpack Compose Version: 1.2.0-beta01
Example:
Text(
modifier = Modifier.pointerInput(Unit) {
detectTapGestures(
onPress = { offset ->
Log.d("", "onPress $offset")
},
onTap = { offset ->
Log.d("", "onTap $offset")
}
)
},
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore"
)
When Talk back is turned off, the output is as expected:
onPress Offset(151.0, 29.0)
onTap Offset(157.0, 18.0)
onPress Offset(699.0, 62.0)
onPress Offset(391.0, 17.0)
onTap Offset(361.0, -1.0)
onPress Offset(282.0, 85.0)
onPress Offset(729.0, 48.0)
onTap Offset(770.0, 40.0)
When Talk back is turned on, a constant offset is received:
onTap Offset(540.0, 46.0)
onPress Offset(540.0, 46.0)
onTap Offset(540.0, 46.0)
onPress Offset(540.0, 46.0)
onTap Offset(540.0, 46.0)
onPress Offset(540.0, 46.0)
onTap Offset(540.0, 46.0)
onPress Offset(540.0, 46.0)
It is returning the center offset of the view when TalkBack is enabled. After stepping through the code for detectTapGestures in TapGestureDetector.kt, it appears awaitPointerEvent() in waitForUpOrCancellation returns a constant position if TalkBack is enabled.
Is there a way around this issue or is this a google bug? Any help is greatly appreciated!