Created
June 14, 2023 02:05
-
-
Save mattrob33/ceb1cb47bb97649a7544929a64d89f9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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