Skip to content

Instantly share code, notes, and snippets.

@mattrob33
Created June 14, 2023 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattrob33/ceb1cb47bb97649a7544929a64d89f9c to your computer and use it in GitHub Desktop.
Save mattrob33/ceb1cb47bb97649a7544929a64d89f9c to your computer and use it in GitHub Desktop.
/**
* Intercept [MotionEvent.ACTION_DOWN] events.
*/
fun Modifier.onPress(pressHandler: (offset: Offset) -> Unit): Modifier {
return this.pointerInteropFilter { event ->
when (event.action) {
MotionEvent.ACTION_DOWN -> pressHandler(Offset(event.x, event.y))
else -> return@pointerInteropFilter false
}
true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment