PointerInputFilter
abstract class PointerInputFilter
A PointerInputFilter represents a single entity that receives PointerInputChange
s), interprets
them, and consumes the aspects of the changes that it is react to such that other
PointerInputFilters don't also react to them.
Properties
val size: IntSize
The layout size assigned to this PointerInputFilter
.
open val interceptOutOfBoundsChildEvents: Boolean
Intercept pointer input that children receive even if the pointer is out of bounds.
If true
, and a child has been moved out of this layout and receives an event, this will
receive that event. If false
, a child receiving pointer input outside of the bounds of this
layout will not trigger any events in this.
open val shareWithSiblings: Boolean
If false
, then this PointerInputFilter
will not allow siblings under it to respond to
events. If true
, this will have the first chance to respond and the next sibling under will
then get a chance to respond as well. This trigger acts at the Layout level, so if any
PointerInputFilter
s on a Layout has shareWithSiblings
set to true
then the Layout will
share with siblings.
Setting this true everywhere or high in the UI tree can negatively impact performance. Therefore, use it sparingly and only at the nearest shared parent of the two target UI elements.
Functions
abstract fun onPointerEvent(pointerEvent: PointerEvent, pass: PointerEventPass, bounds: IntSize)
Invoked when pointers that previously hit this PointerInputFilter
have changed. It is
expected that any PointerInputChange
s that are used during this event and should not be
considered valid to be used in other filters should be marked as consumed by calling
PointerInputChange.consume
.
Parameters
pointerEvent | The list of PointerInputChange s with positions relative to this PointerInputFilter . |
pass | The PointerEventPass in which this function is being called. |
bounds | The width and height associated with this PointerInputFilter . |
abstract fun onCancel()
Invoked to notify the handler that no more calls to PointerInputFilter
will be made, until
at least new pointers exist. This can occur for a few reasons:
- Android dispatches ACTION_CANCEL to Compose.
- This
PointerInputFilter
is no longer associated with a LayoutNode. - This
PointerInputFilter
's associated LayoutNode is no longer in the composition tree.