Skip to content

Instantly share code, notes, and snippets.

@andreymusth
Created July 19, 2021 06:00
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 andreymusth/f7d7299a23ef57d7f4013794fbdc35ea to your computer and use it in GitHub Desktop.
Save andreymusth/f7d7299a23ef57d7f4013794fbdc35ea to your computer and use it in GitHub Desktop.
pointer input hit test
override fun hitTest(
pointerPosition: Offset,
hitPointerInputFilters: MutableList<PointerInputFilter>
) {
if (isPointerInBounds(pointerPosition) && withinLayerBounds(pointerPosition)) {
// If the pointer is in bounds, we hit the pointer input filter, so add it!
hitPointerInputFilters.add(modifier.pointerInputFilter)
// Also, keep looking to see if we also might hit any children.
// This avoids checking layer bounds twice as when we call super.hitTest()
val positionInWrapped = wrapped.fromParentPosition(pointerPosition)
wrapped.hitTest(positionInWrapped, hitPointerInputFilters)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment