PointerEvent
Describes a pointer input change event that has occurred at a particular point in time.
PointerEvent
expect class PointerEvent
internal constructor(
changes: List<PointerInputChange>,
internalPointerEvent: InternalPointerEvent?,
)
Describes a pointer input change event that has occurred at a particular point in time.
Secondary Constructors
constructor(changes: List<PointerInputChange>)
Parameters
| changes | The changes. |
Properties
val changes: List<PointerInputChange>
The changes.
val buttons: PointerButtons
The state of buttons (e.g. mouse or stylus buttons) during this event.
val keyboardModifiers: PointerKeyboardModifiers
The state of modifier keys during this event.
var type: PointerEventType
The primary reason the PointerEvent was sent.
actual class PointerEvent
internal actual constructor(
/** The changes. */
actual val changes: List<PointerInputChange>,
internal val internalPointerEvent: InternalPointerEvent?,
)
Describes a pointer input change event that has occurred at a particular point in time.
Secondary Constructors
actual constructor(changes: List<PointerInputChange>) : this(changes, null)
Parameters
| changes | The changes. |
Properties
val motionEvent: MotionEvent?
The underlying Android MotionEvent that triggered this PointerEvent.
This property provides access to the raw MotionEvent for retrieving platform-specific
information not yet exposed by the Compose PointerEvent API (e.g., stylus tilt angle).
Important Considerations:
- Read-Only: The returned
MotionEventis strictly read-only. Modifying it will lead to unpredictable behavior. - Transient: Do not store a reference to this
MotionEvent. The Android framework may recycle it, rendering its state undefined and causing errors if accessed later. Access the data only within the scope where thePointerEventis received. - Metadata Only: This
MotionEventshould not be used for primary input handling logic (e.g., determining pointer position or button presses). Rely on the properties ofPointerEventandPointerInputChangefor this purpose. TheMotionEventis intended solely for accessing supplemental metadata. - Nullability: This property will be
nullin two cases: * ThePointerEventwas fabricated within Compose (i.e., not directly from a system input event). * ThePointerEventhas already been dispatched within the Compose input system. (Seeandroidx.compose.ui.samples.PointerEventMotionEventSamplefor details).
@get:MotionEventClassification
val classification: Int
Returns
``MotionEvent's classification(https://developer.android.com/reference/android/view/MotionEvent#getClassification()).
actual val buttons = PointerButtons(motionEvent?.buttonState ?: 0)
actual val keyboardModifiers = PointerKeyboardModifiers(motionEvent?.metaState ?: 0)
actual var type: PointerEventType
Functions
fun component1(): List<PointerInputChange>
fun copy(changes: List<PointerInputChange>, motionEvent: MotionEvent?): PointerEvent
